Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
error json
#2
Look at:
halo = json.loads(j)
print(halo)
# json.loads() should give back a python dictionary
print(type(halo))
for user in halo: will loop over key in dictionary,not both key and values.
It's now a string you try to get key from not a dictionary,just to make your error.
>>> s = 'foo'
>>> s['faceAttributes']
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
TypeError: string indices must be integers

# So a string need integer,but this is not what you want
>>> s[0]
'f'
Reply


Messages In This Thread
error json - by pifko22 - Apr-13-2019, 01:05 AM
RE: error json - by snippsat - Apr-13-2019, 01:33 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  json loads throwing error mpsameer 8 741 Jan-23-2024, 07:04 AM
Last Post: deanhystad
  json decoding error deneme2 10 3,740 Mar-22-2023, 10:44 PM
Last Post: deanhystad
  python requests library .JSON() error mHosseinDS86 6 3,490 Dec-19-2022, 08:28 PM
Last Post: deanhystad
  Read nested data from JSON - Getting an error marlonbown 5 1,401 Nov-23-2022, 03:51 PM
Last Post: snippsat
  JSON Decode error when using API to create dataframe Rubstiano7 4 2,978 Jan-11-2021, 07:52 PM
Last Post: buran
  Empty response to request causing .json() to error t4keheart 1 10,118 Jun-26-2020, 08:35 PM
Last Post: bowlofred
  empty json file error mcmxl22 1 10,195 Jun-17-2020, 10:20 AM
Last Post: buran
  json.dumps output error in python3 prayuktibid 2 2,684 Jan-21-2020, 06:41 AM
Last Post: prayuktibid
  Reading JSON - error jmair 2 2,254 May-22-2019, 07:25 PM
Last Post: jmair
  Error message in Jupyter Notebook with json diet 4 5,581 Jun-17-2018, 08:32 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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