I have this JSON in a file: { "maps": [ { "id": "blabla", "iscategorical": "0" }, { "id": "blabla", "iscategorical": "0" } ], "masks": [ "id": "valore" ], "om_points": "value", "parameters": [ "id": "valore" ] }I wrote this script which prints all of the json text: json_data=open(file_directory).read() data = json.loads(json_data) pprint(data)How can I parse the file and extract single values?
So you're almost there. JSON is very similar to the data structure called a dictionary. JSON stores "key:value" relationships where keys are unique and values are not. Items are separated by commas. We index into dictionaries and JSON by using the same syntax we use for indexing lists and arrays, which is bracket indexing. To access a value in JSON I would say something like