我试图加载一个JSON文件来解析嵌套在根对象中的内容。目前我已经打开了JSON文件,并以这种方式加载。
with open(outputFile.name) as f:
data = json.load(f)
为了回答这个问题,这里举例说明JSON文件的内容是怎样的。
"rootObject" :
"person" :
"address" : "some place ave. 123",
"age" : 47,
"name" : "Joe"
"kids" :
"age" : 20,
"name" : "Joey",
"studySubject":"math"
"age" : 16,
"name" : "Josephine",
"studySubject":"chemistry"
"parents" :
"father" : "Joseph",
"mother" : "Joette"
我如何访问 "rootObject "中的嵌套对象,如 "人"、"孩子 "及其内容和 "父母"?