1import json
2
3studentJson ="""{
4 "id": 1,
5 "name": "john wick",
6 "class": null,
7 "percentage": 75,
8 "email": "jhon@pynative.com"
9}"""
10
11student = json.loads(studentJson)
12if not (student.get('subject') is None):
13 print("value is present for given JSON key")
14 print(student.get('subject'))
15else:
16 print("using a default value for a given key")
17 print(student.get('subject', 'Science'))