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

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -