开发者

Is there simple way to encode json data in Django? [closed]

It开发者_运维技巧9;s difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I will get data like this from OpenID provider:

{"identity":"http:\/\/admin.lol.com\/","provider":"http:\/\/lol.com\/server\/",
"name":{"full_name":"\u0421\u0435\u0440\u0433\u0435\u0439 \u0421\u0435\u0440\u0433\u0435\u0439"},
"nickname":"admin","email":"admin@lol.ru","gender":"M","dob":"1985-01-31"}

How to get this data?


Django by default bundles the simplejson library at django.utils.simplejson (http://undefined.org/python/#simplejson). Additionally if you're using python 2.6 or better you can simply import json and you will get the builtin json libraryhttp://docs.python.org/library/json.html. There are also a multitude of other python json libraries, but those two should be vastly more than adequate.

Once you have decided on a library to use you will simply need to pass your json string to the decoder of that library. For the builtin json library that would be:

data = json.loads(your_json_string_here)


http://docs.python.org/library/json.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜