[Solved] TypeError: JSON string indices must be integers [closed]


There is no way to add extra indexes after “service_name”, as it returns already a string. Dictionaries don’t work in such a way that you can get different keys just by adding them after eachother, this would not make sense programatically. You should therefore create a new dictionary with the keys you want.

return render_template('index.html',
   data=json.dumps({
       'service_name': data['archive'][0]['service_name'],
       'date': data['archive'][0]['date'],
       'summary': data['archive'][0]['summary']
   }))

If it is not a problem that the “status” and “details” keys also get into the dictionary, you can also pass in the whole dictionary.

return render_template('index.html',
    data=json.dumps(data['archive'][0]))

1

solved TypeError: JSON string indices must be integers [closed]