Мой API должен возвращать что-то с помощью типа json, поэтому я установил Content-Type в application/json?
Это мой url, я не хочу, чтобы символы были экранированы.
Я использую webpy framework.
def GET(self):
web.header('Content-Type', 'application/json')
url = "http://www.reddit.com/r/pics/hot.json"
hdr = { 'User-Agent' : 'super happy flair bot by /u/spladug' }
req = urllib2.Request(url, headers=hdr)
html = urllib2.urlopen(req).read()
gold = json.loads(html)
return render.callback(gold)
Это результат выборки:
{u'kind': u'Listing'}
Я не хочу, чтобы персонаж сбежал.
Кто-нибудь может мне помочь?
# If ensure_ascii is True (the default),
# all non-ASCII characters in the output are escaped.
gold = json.loads(html, ensure_ascii=0, sort_keys=1, indent=4)