(Mar-10-2022, 11:09 AM)ilknurg Wrote: For parsing it, im trying to write this content in a JSON file and i tried read and parse it.It's already a data structure so making it JSON and read just a extra unnecessary step.
Just a copy of your data and make into a
lst
variable.lst = [ [{"Manufacturer": "VMware, Inc.", "Model": "VMware7,1", "Name": "DC01"}], [{"Index": "1", "IPAddress": ["192.168.1.240,fe80::350e:d28d:14a5:5cbb"]}], [{"Name": "DC01", "UserName": None}], ]
>>> for i in lst: ... print(i[0].get('Name')) ... DC01 None DC01 >>> for i in lst: ... print(i[0].get("Manufacturer")) ... VMware, Inc. None NoneAgain just a copy of your data and the extra JSON step.
import json with open('data.json', 'r') as myfile: data = json.load(myfile)
>>> for i in data: ... print(i[0].get('Name')) ... DC01 None DC01 >>> for i in data: ... print(i[0].get("Manufacturer")) ... VMware, Inc. None None