如何使用熊猫规范此嵌套json

时间:2019-03-29 15:54:38

标签: json pandas normalization

我有这种要规范化的json。我将它与大熊猫一起使用:

>>> df = json_normalize(data=resp.json()['issues'],meta=['key', ['fields', 'summary']], errors='ignore')
>>> df['fields.versions']
0     [{'self': 'https://*.*.*.*...

fields.versions无法标准化。你能帮忙吗?

版本是数组,而不是字典,因此很难规范化。 json如下:

    {
        "expand": "schema,names",
        "startAt": 0,
        "maxResults": 50,
        "total": 49,
        "issues": [
            {
                "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
                "id": "5180791",
                "self": "https://*.*.*.*/rest/api/latest/issue/5180791",
                "key": "XXX-2439",
                "fields": {
                    "summary": "Demo",
                    "customfield_28607": {
                        "self": "https://*.*.*.*/rest/api/2/customFieldOption/237214",
                        "value": "N",
                        "id": "237214"
                    },
                    "created": "2019-03-27T12:49:19.000+0200",
                    "customfield_11890": null,
                    "versions": [
                        {
                            "self": "https://*.*.*.*/rest/api/2/version/164021",
                            "id": "164021",
                            "description": "XXX",
                            "name": "XXX",
                            "archived": false,
                            "released": false,
                            "releaseDate": "2019-04-01"
                        }
                    ],
                }
            }
        ]
    }

0 个答案:

没有答案