The json library can parse JSON from strings or files. The library parses JSON into a Python dictionary or list. It can also convert Python dictionaries or lists into JSON strings.
Parsing JSON
Take the following string containing JSON data:
It can be parsed like this:
and can now be used as a normal dictionary:
You can also convert the following to JSON:
simplejson
The JSON library was added to Python in version 2.6. If you’re using an earlier version of Python, the simplejson library is available via PyPI.
simplejson mimics the json standard library. It is available so that developers that use older versions of Python can use the latest features available in the json lib.
You can start using simplejson when the json library is not available by importing simplejson under a different name:
After importing simplejson as json, the above examples will all work as if you were using the standard json library.
http://docs.python-guide.org/en/latest/scenarios/json/
No hay comentarios:
Publicar un comentario