You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/scenarios/json.rst
+12-4Lines changed: 12 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
JSON
2
2
====
3
3
4
-
The `json <https://docs.python.org/2/library/json.html>`_ library can parse JSON from strings or files. When parsing, the library converts the JSON into a Python dictionary or list. It can also parse Python dictionaries or lists into JSON strings.
4
+
The `json <https://docs.python.org/2/library/json.html>`_ 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.
5
5
6
6
Parsing JSON
7
7
------------
@@ -26,7 +26,7 @@ and can now be used as a normal dictionary:
26
26
print(parsed_json['first_name'])
27
27
"Guido"
28
28
29
-
You can also convert a the following to JSON:
29
+
You can also convert the following to JSON:
30
30
31
31
.. code-block:: python
32
32
@@ -43,6 +43,14 @@ You can also convert a the following to JSON:
43
43
simplejson
44
44
----------
45
45
46
-
`simplejson <https://simplejson.readthedocs.org/en/latest/>`_ is the externally maintained development version of the json library.
46
+
The JSON library was added to Python in version 2.6. If you're using an earlier version of Python, the `simplejson <https://simplejson.readthedocs.org/en/latest/>`_ library is available via PyPI.
47
47
48
-
simplejson mimics the json standard library, it is available so that developers that use an older version of python can use the latest features available in the json lib.
48
+
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.
49
+
50
+
You can start using simplejson when the json library is not available by importing simplejson under a different name:
51
+
52
+
.. code-block:: python
53
+
54
+
import simplejson as json
55
+
56
+
After importing simplejson as json, the above examples will all work as if you were using the standard json library.
0 commit comments