Skip to content

Commit f1e196a

Browse files
committed
Commit last few necessary edits
These were all previously ignored in the last two pull requests.
1 parent 37ed5fc commit f1e196a

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

docs/scenarios/json.rst

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ The `json <https://docs.python.org/2/library/json.html>`_ library can parse JSON
66
Parsing JSON
77
------------
88

9-
The json libary is imported like this:
10-
11-
.. code-block:: python
12-
13-
import json
14-
159
Take the following string containing JSON data:
1610

1711
.. code-block:: python
@@ -22,26 +16,28 @@ It can be parsed like this:
2216

2317
.. code-block:: python
2418
25-
converted_dict = json.loads(json_string)
19+
import json
20+
parsed_json = json.loads(json_string)
2621
2722
and can now be used as a normal dictionary:
2823

2924
.. code-block:: python
3025
31-
print(converted_dict['first_name'])
26+
print(parsed_json['first_name'])
3227
"Guido"
3328
34-
You can also convert a dictionary to JSON:
29+
You can also convert a the following to JSON:
3530

3631
.. code-block:: python
3732
3833
d = {
3934
'first_name': 'Guido',
40-
'second_name': 'Rossum'
35+
'second_name': 'Rossum',
36+
'titles': ['BDFL', 'Developer'],
4137
}
4238
4339
print(json.dumps(d))
44-
"{'first_name':'Guido','last_name':'Rossum'}"
40+
'{"first_name": "Guido", "last_name": "Rossum", "titles": ["BDFL", "Developer"]}'
4541
4642
4743
simplejson

0 commit comments

Comments
 (0)