Answers for "json data default"

0

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'))
Posted by: Guest on August-28-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language