Mar-10-2022, 10:58 AM
Sure, that the square-brackets are missing in the JSON file? If yes, then your file is malformed and could not parse without modification. The JSON module of the Python standard lib is very strict.
If this is the content of your input file:
Sometimes people add line by line JSON data.
This is also not parsable with
If this is the content of your input file:
{"Manufacturer": "VMware, Inc.", "Model": "VMware7,1", "Name": "DC01"} , {"Index": "1", "IPAddress": "192.168.1.240,fe80::350e:d28d:14a5:5cbb" }Then you may add [ and ] to the str.
# first you just read your json file # here I just put the raw str into the code, because of laziness... data_as_text = """{"Manufacturer": "VMware, Inc.", "Model": "VMware7,1", "Name": "DC01"} , {"Index": "1", "IPAddress": "192.168.1.240,fe80::350e:d28d:14a5:5cbb" }""" # parsing my_data = json.loads("[" + data_as_text + "]")But it's better to have valid JSON content.
Sometimes people add line by line JSON data.
This is also not parsable with
json
because it's not valid.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!