我有多个 JSON 文件要覆盖,但似乎无法访问下面的特定文本(干扰)。这是文件中一行的示例:
{"extracted":"high","nameid":3201932,"users":{"name":[{"ids":[28,37],"text":"distracter"}],"symbols":[]}}
下面是我编写的返回空结果的代码:
data = []
with open(fileName, 'r') as file_to_read:
for line in file_to_read:
data.append(json.loads(line))
json_tree = objectpath.Tree(data)
text_result= tuple(json_tree.execute('$.users.name[@.text]'))
return text_result