Parsing JSON-file with Python in Django -


i have query fetch json-file , want show data in table in html. error: typeerror: string indices must integers in line: 'status': item['status'],. problem outer brackets, because missing in json or what?

views.py code

json_obj = urllib2.urlopen(url) data = json.load(json_obj) results = [] item in data:     results.append({         'status': item['status'],         'device': item['device'],        }) return render(request, 'index/index.html', {'objects_list': results}) 

json-file:

{   “version": “3.62”,   "treesize": 2,   "": [     {       “status”: “up”,       "device": “somedevicename1”,     }     {       “status”: “up”,       "device": “somedevicename2”,     }] } 

i don't know whether accidentally copied json content wrong or not should is:

>>> item in data[""]: ...     results.append({ ... 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -