Question 10
Back to Exercise
What is the output of the following Python program?
import json
s = json.dumps({"b": 1, "a": [True, None]}, sort_keys=True)
print(s)
print(json.loads(s)["a"], type(json.loads("3.0")).__name__)
- A {'a': [True, None], 'b': 1} [True, None] float
- B {"b": 1, "a": [true, null]} [true, null] str
- C {"a": [true, null], "b": 1} [True, None] float Correct
- D {"a": [true, null], "b": 1} ['true', 'null'] float
Correct Answer: Option C
JSON uses double quotes, true and null; sort_keys orders the keys. loads converts them back to True and None.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!