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)

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'})
"""
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.