Jan-22-2024, 10:52 AM
(Jan-22-2024, 09:55 AM)mpsameer Wrote: the output returned from ssh1.send_command("show env power | json") is class strAs mention you most make a variable and post what the result is.
It most return a valid json string for
json.load()
to work.arista_commands = ["show env power | json"] for command in arista_commands: raw_output = ssh1.send_command(command) print(raw_output) # Most return a valid json stringTo give a example on how a valid json string looks.
>>> import json >>> raw_output = '{"name":"John", "age":30, "city":"New York"}' >>> data = json.loads(raw_output) >>> data {'age': 30, 'city': 'New York', 'name': 'John'} >>> data['city'] 'New York'