python convert dict to json array code example
Example 1: python json to dict
import json
info = '{"name": "Dave","City": "NY"}'
res = json.loads(info)
print(res)
print("Datatype of the serialized JSON data : " + str(type(res)))
info = open('data.json',)
res = json.load(info)
print(res)
print("Datatype after deserialization : " + str(type(res)))
Example 2: python dict into json string
import json
dictionary ={
"A": 5,
"B": "guys",
}
json_object = json.dumps(dictionary, indent = 4)
print(json_object)
{
"A": 5,
"B": "guys",
}