Mar-10-2022, 11:09 AM
I get your suggessions. I have 3 vmi commands and there are the result of its.
So the output_array is :
When i use json validator it says that it is a valid json.
Now i tried to run this code
Name
Manucaturer
Username.
i'm stuck here
[{'Manufacturer': 'VMware, Inc.', 'Model': 'VMware7,1', 'Name': 'DC01'}] [{'Index': '1', 'IPAddress': ['192.168.1.240,fe80::350e:d28d:14a5:5cbb']}] [{'Name': 'DC01', 'UserName': None}]They are seperate strings. I create an output_array and appent all these 3 lines into it.
So the output_array is :
[[{'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 parsing it, im trying to write this content in a json file and i tried read and parse it.
When i use json validator it says that it is a valid json.
Now i tried to run this code
import json with open('data5.json', 'r') as myfile: data = json.load(myfile) for i in data: print(data['Name'])And again getting the error
Traceback (most recent call last): File "C:\Users\DELL\AppData\Roaming\JetBrains\PyCharmCE2021.3\scratches\scratch_38.py", line 5, in <module> print(data['Name']) TypeError: list indices must be integers or slices, not strI want to reach this values
Name
Manucaturer
Username.
i'm stuck here