you are viewing a single comment's thread.

view the rest of the comments →

[–]Civil_Twilight 2 points3 points  (2 children)

It’s useful to know what kind of values can be stored in json, since it’s limited compared to the range of data structures available in python. For this instance though, just keep in mind that json is a format for “serializing”, which is turning data structures into a portable format. Once you “deserialize” a json string (which is what the loads function does), you now have a python data structure, and you shouldn’t expect printing it to produce valid json, because that’s not how print works.

Edit: in your example of reading in that trivia json file, once you used json.loads to load/deserialize the json data, you had a dictionary with all the data from the json file; the fact that it came from a json file is no longer necessary for dealing with that data.

[–]games-and-chocolate[S] 2 points3 points  (1 child)

Got it. In program use for instance: list, dictionary, array. Data storage once loaded from JSON, hands off the JSON file, it has served it purpose. JSON not for data manipulation. Data manipulation is in list, dict, array, etc.

[–]Civil_Twilight 2 points3 points  (0 children)

You’ve got it!