下面代码,举例说明了json如何创建和解析含有中文的json串:
#coding=gbk
import os
import sys
reload(sys)
sys.setdefaultencoding('gbk')
import json
a = {}
a['width'] = 123
a['height'] = 123
a['info'] = 'zsdfjkl12'
a['zhongwen'] = "数据库''\""
json_str = json.dumps(a,ensure_ascii=False)
xx =json.loads(json_str,encoding='gbk')
print xx['zhongwen'].encode('gbk')