I need a clarification. If I for example do a view with a serialized object:
def sample(request):
res = [{'name':'man'}]
encoded = json.dumps(res)
return render_to_response('sample/example.html',{'encoded':encoded} )
In my templates I pass:
{{encoded}}
Now from a python script can I do:
data = json.loads(urllib2.urlopen(url/to/site).read()
It says ValueError: No JSON object could be decoded. But isn't {{encoded}} a json object? And if so how would I get it?
Thank you
print urllib2.urlopen(url/to/site).read()first. I'm betting that Django escapes the string."should be a'. See my answer.