-1

I am trying my first steps with python and json and hope you can halp me with this. I am getting a json in a variable which looks like this:

host10=[{'hostid': '10084', 'proxy_hostid': '0'},
 {'hostid': '10085', 'proxy_hostid': '1'}]

when I run

hosts = json.loads(host10)
  print(hosts)

I am getting the error:

raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not list

what do I wrong?

cyberoner1
  • 51
  • 1
  • 7
  • No, it’s not JSON but a native Python list of dictionaries. – kirjosieppo Aug 10 '22 at 10:10
  • [`json.loads`](https://docs.python.org/3/library/json.html#json.loads) accepts a string as input - you are providing a list of dicts instead. The error is pretty self-explanatory – alex Aug 10 '22 at 10:10

1 Answers1

1

you can find your answer here

import json
json.dumps(list_name)