Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can i parse my output?
#4
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:
{"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!
Reply


Messages In This Thread
How can i parse my output? - by ilknurg - Mar-10-2022, 10:30 AM
RE: How can i parse my output? - by Gribouillis - Mar-10-2022, 10:42 AM
RE: How can i parse my output? - by ilknurg - Mar-10-2022, 10:47 AM
RE: How can i parse my output? - by DeaD_EyE - Mar-10-2022, 10:58 AM
RE: How can i parse my output? - by Gribouillis - Mar-10-2022, 11:02 AM
RE: How can i parse my output? - by ilknurg - Mar-10-2022, 11:09 AM
RE: How can i parse my output? - by DeaD_EyE - Mar-10-2022, 12:00 PM
RE: How can i parse my output? - by ilknurg - Mar-10-2022, 12:15 PM
RE: How can i parse my output? - by DeaD_EyE - Mar-10-2022, 12:24 PM
RE: How can i parse my output? - by ilknurg - Mar-10-2022, 12:35 PM
RE: How can i parse my output? - by menator01 - Mar-10-2022, 12:29 PM
RE: How can i parse my output? - by ilknurg - Mar-10-2022, 12:39 PM
RE: How can i parse my output? - by snippsat - Mar-10-2022, 12:41 PM
RE: How can i parse my output? - by ilknurg - Mar-10-2022, 01:07 PM
RE: How can i parse my output? - by DeaD_EyE - Mar-10-2022, 12:50 PM
RE: How can i parse my output? - by snippsat - Mar-10-2022, 01:43 PM
RE: How can i parse my output? - by ilknurg - Mar-10-2022, 01:51 PM
RE: How can i parse my output? - by menator01 - Mar-10-2022, 02:08 PM
RE: How can i parse my output? - by ilknurg - Mar-10-2022, 02:19 PM
RE: How can i parse my output? - by snippsat - Mar-10-2022, 02:16 PM
RE: How can i parse my output? - by Gribouillis - Mar-10-2022, 02:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How can i parse my output? ilknurg 4 1,627 Mar-16-2022, 03:27 PM
Last Post: snippsat
  Unable to parse JSON output dragan979 1 3,587 Apr-20-2018, 02:24 PM
Last Post: dragan979

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020