python - How to encapsulate JSON in parentheses? -
i have code :
objects = event.objects.all() = 0 dict = {} small_dict = {} o in objects: small_dict = {'id': o.id, 'url': o.url, 'name': o.name, 'image': o.image} dict[str(i+1)] = small_dict small_dict = {} return httpresponse( simplejson.dumps(dict), content_type = 'application/javascript; charset=utf8' ) and gives me :
{"1": {"url": "http://www.rte.ie/tv/crimecall/", "image": "http://img.rasset.ie/0002c8d0-250.jpg", "id": 2, "name": "crimecall"}} how can further encapsulate between () parentheses ? because without them i'm getting error when parsing them in php.
you can way, it's not viewable in browser now. i'f that's not problem, here's code :
callback = request.get.get('callback', '') objects = event.objects.all() = 0 dict = {} small_dict = {} o in objects: small_dict = {'id': o.id, 'url': o.url, 'name': o.name, 'image': o.image} dict[str(i+1)] = small_dict small_dict = {} response = simplejson.dumps(dict) response = callback + '(' + response + ')'; return httpresponse(response, mimetype ='application/json; charset=utf8')
Comments
Post a Comment