How to parse the dynamic numeric keys with following json. I can able to do manually json_text['entities']['0']['uid'], how can I dynamically iterate with all keys and get all uid's
{
"entities": {
"0":{
"uid": "3769fcb3-8312-41b8-a5c9-3c24b6a9ce96"
},
"1":{
"uid": "3769fcb3-8312-41b8-a5c9-3c24b6a9ce97"
},
"2":{
"uid": "3769fcb3-8312-41b8-a5c9-3c24b6a9ce98"
}
"3":{
;
}
:
:
:
}
}
Code:
import os, json
import pandas as pd
path_to_json = '/home/sshuser/data/'
json_files = [pos_json for pos_json in os.listdir(path_to_json) if pos_json.endswith('.json')]
print(json_files)
# here I define my pandas Dataframe with the columns I want to get from the json
# we need both the json and an index number so use enumerate()
for index, js in enumerate(json_files):
with open(os.path.join(path_to_json, js)) as json_file:
json_text = json.loads(json_file.read())
uids= json_text['entities']['0']['uid']
print(seeMore)