0

I am attempting to write a JSONP application and think that it is not working because the JSON my code is returning has surrounding quotation marks.

For example when I call the webapp using http://rest-client.googlecode.com/ it returns the following

"callbackfunctionname({'Last': 'Doe', 'First': 'John'})"

Comparing this to a public url I am using which works the only difference I can see is the surrounding quotation marks.

Does anybody know how I can remove these?

Thanks

Jim


def get(self):

json = "{'Last': 'Doe', 'First': 'John'}"
		json = self.request.get("callback") + '(' + json + ')'
		logging.debug("json=" + json)
 		self.response.set_status(200)
		self.response.headers['Content-Type'] = "application/json"	
		self.response.headers['Content-Length'] = len(json)
		self.response.content_type = "application/json"
		simplejson.dump(json, self.response.out)
2
Contributors
2
Replies
4
Views
8 Years
Discussion Span
Last Post by jculverwell
1

The function s.strip() will do ...

s = repr("callbackfunctionname({'Last': 'Doe', 'First': 'John'})")

print s
# remove leading and trailing character '"'
print(s.strip('"'))

"""
my output -->
"callbackfunctionname({'Last': 'Doe', 'First': 'John'})"
callbackfunctionname({'Last': 'Doe', 'First': 'John'})
"""
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.