Skip to content Skip to sidebar Skip to footer

String Indices Must Be Integers Error

I am looking to parse out json obtained from following code: import json from watson_developer_cloud import ToneAnalyzerV3Beta import urllib.request import codecs reader = codecs.g

Solution 1:

json.dumps() converts an object into a string. So, data is a string. So, you can't index it with 'document_tone' key (it's not a dict). Maybe you meant json.loads()? Or maybe tone_analyzer.tone() already returns a dict and there is no need for loads()?


Post a Comment for "String Indices Must Be Integers Error"