Getting values from JSON using Python
Getting values from JSON using Python
If you want to iterate over both keys and values of the dictionary, do this:
for key, value in data.items():
print key, value
What error is it giving you?
If you do exactly this:
data = json.loads({lat:444, lon:555})
Then:
data[lat]
SHOULD NOT give you any error at all.
Getting values from JSON using Python
Using Python to extract a value from the provided Json
Working sample:-
import json
import sys
//load the data into an element
data={test1 : 1, test2 : 2, test3 : 3}
//dumps the json object into an element
json_str = json.dumps(data)
//load the json to a string
resp = json.loads(json_str)
//print the resp
print (resp)
//extract an element in the response
print (resp[test1])