0

In the file there is a JSON data I'm trying to retrieve data from "sai" only
https://drive.google.com/file/d/1r7tnZjFSvggfkI890vgmRmiv16_kAbY4/view?usp=sharing

import json
with open("student_detailsdb.json","r") as fp:
    data = json.load(fp)
for i in data:
    print(i["sai"])
Matiiss
  • 5,970
  • 2
  • 12
  • 29
  • Please include the JSON itself in your post, not as a link – OneCricketeer Dec 31 '21 at 07:54
  • Does this answer your question? [Check if a given key already exists in a dictionary](https://stackoverflow.com/questions/1602934/check-if-a-given-key-already-exists-in-a-dictionary) – kaya3 Jan 01 '22 at 04:36

1 Answers1

0

Pls check the "sai" key present in the iteration (i), then it will print only sai details

import json
with open("student_detailsdb.json","r") as fp:
    data = json.load(fp)
for i in data:
    if "sai" in i:
       print(i["sai"])
Ananth.P
  • 445
  • 2
  • 8