python - Remove unicode strings in rendered template -
i'm trying return json object under address:
http://ntt.vipserv.org/data/shows
but result i'm getting :
{'1': {'url': u'http://www.rte.ie/tv/crimecall/', 'image': u'http://img.rasset.ie/0002c8d0-250.jpg', 'id': u'2', 'name': u'crimecall'}}
how rid fo unicode strings ?
my code:
objects = show.objects.all() = 0 dict = {} small_dict = {} o in objects: small_dict = {'id': o.id.decode('ascii'), 'url': o.url.decode('ascii'), 'name': o.name.decode('ascii'), 'image': o.image.decode('ascii')} dict[str(i+1)] = small_dict small_dict = {}
i'd suggest using json module instead of trying write json encoder yourself. correctly format strings in double quotes , without u in front of string.
Comments
Post a Comment