Python JSON Deserialization














































Python JSON Deserialization




Deserializing JSON :

The Deserialization is opposite of Serialization, i.e. conversion of JSON object into their respective Python objects. The 
load() method is used for it.

with open("Sample.json", "r") as read_it: 
	data = json.load(read_it) 


json_var =""" 
{ 
	"Country": { 
		"name": "INDIA", 
		"Languages_spoken": [ 
			{ 
				"names": ["Hindi", "English", "Bengali", "Telugu"] 
			} 
		] 
	} 
} 
"""
var = json.loads(json_var) 

 If you have used Json data from another program or obtained as a string format of Json, then it can easily be deserialized with load(), which is usually used to load from string, otherwise the root object is in list or dict.



Comments