Python:循环遍历JSON文件

Python:循环遍历JSON文件,python,json,Python,Json,我不知道如何循环通过这个特殊的结构,其中顶级键A1和B6是随机的 我想能够输出名称,x,y和yr { "A1": { "msgs": ["Something there"], "name": "Mary White", "x": 132, "y": 73, "yr": 1978 }, "B6": { "msgs": ["Something here"], "na

我不知道如何循环通过这个特殊的结构,其中顶级键A1和B6是随机的

我想能够输出名称,x,y和yr

{
    "A1": {
        "msgs": ["Something there"],
        "name": "Mary White",
        "x": 132,
        "y": 73,
        "yr": 1978
    },
    "B6": {
        "msgs": ["Something here"],
        "name": "Joe Bloggs",
        "x": 132,
        "y": 73,
        "yr": 2016
    },
...
使用以下命令加载我的JSON

import json

with open('items.json') as data_file:    
    data = json.load(data_file)

遍历
.values()


@ZdaR否,您需要循环查看
.items()
。json在哪里发挥作用?已更新的问题,仅打印出第一个问题one@pee2pee对我来说很好。检查json文件。并尝试打印(数据)。
import json

with open('data.json') as data_file:    
    data = json.load(data_file)
    for v in data.values():
        print(v['x'], v['y'], v['yr'])