Reputation: 41
I'm so I've the value of the ID "8" and don't but I want to get the User value XXX-XXX of the Json. Is there a way to get the value? Thank you, if you can help.
users:{
"XXX-XXX":{
"Info":{
"ID":"8",
"Created": "2021-07-10",
"Plan": "Basic"}},
"DDD-DDD":{
"Info":{
"ID":"10",
"Created": "2021-07-11",
"Plan": "Prime"}}
}
}
Upvotes: 1
Views: 53
Reputation: 2791
You can do this naively using pure python and iterating:
def get_user_value(id_):
for key, user in users.items():
if user['info']['ID'] == id_:
return key
return "Not-Found"
If your data is large, however, you may want to explore more optimized approaches.
Upvotes: 3