json data default
import json
studentJson ="""{
"id": 1,
"name": "john wick",
"class": null,
"percentage": 75,
"email": "[email protected]"
}"""
student = json.loads(studentJson)
if not (student.get('subject') is None):
print("value is present for given JSON key")
print(student.get('subject'))
else:
print("using a default value for a given key")
print(student.get('subject', 'Science'))