I have a json file that is heavily nested.
I am trying to get the Value of key ‘value’ by key ‘uniqueid’ in python.
I have a separate file where i have a list of the unique id and what it means.
I want to do something like a find function where I give the uniqueid and it returns the value of key ‘value’ from the json. Eg. I need to find korea using uniqueid 123456789.
The keys in the json are not unique.And the json file is big with similar pattern.
"Items" : [ {
"type" : "group1",
"columns" : [ {
"fields" : [ {
"type" : "country",
"UniqueID" : "123456789",
"value" : "korea",
}, {
"type" : "country",
"UniqueID" : "987782999",
"value" : “Japan",
} ]
} ]
Input will be appreciated.
At the end you just need to go to the fields list and iterate it looking for an specific id
for i in myDict["Items"][0]["columns"][0]["fields"]:
if i["UniqueID"] == "123456789":
print(i["value"])