python json how to get value code example
Example 1: python json string to object
import json
x = '{ "name":"John", "age":30, "city":"New York"}'
y = json.loads(x)
print(y["age"])
Example 2: get value json python
print(json_object_string)
OUTPUT
{"id":"20", "name":"Bob"}
json_object = json.loads(json_object_string)
print(json_object["name"])
OUTPUT
Bob
Example 3: python get value from json
for key, value in data.items():
print key, value