Program - Check if there is a value for a key in JSON
Topic: Program - Check if there is a value for a key in JSON
Solution
import json studentJson ="""{ "id": 1, "name": "Ishwar Venugopal", "class": null, "percentage": 35, "email": "ishwarraja@gmail.com" }""" student = json.loads(studentJson) if not (student.get('email') is None): print("value is present for given JSON key") print(student.get('email')) else: print("value is not present for given JSON key")
List all Python Programs