JSONB嵌套数组jsonb_array_elements

时间:2020-11-11 14:58:55

标签: json

首先,感谢您的支持。我需要从嵌套的json数组中提取一些字段。我的jsonb数据如下:

    "id": 1,
    "name": "TestPolicy",
    "status": "PUBLISHED",
    "country": "AT",
    "validFrom": 1511478000000,
    "textBlocks": [
        {
            "id": 3,
            "name": null,
            "status": null,
            "country": null,
            "language": "de",
            "reference": null,
            "usageText": [
                {
                    "id": 3,
                    "value": "Textblock 1",
                    "language": null,
                    "mimeType": "text/plain",
                    "textBlockId": 3
                }
            ],
            "validFrom": null,
            "majorVersion": null,
            "minorVersion": null,
            "usageDefinitions": [
                {
                    "id": 3,
                    "usages": [
                        {
                            "id": 4,
                            "usage": {
                                "id": 10,
                                "name": "DATAPROCESSING",
                                "lockDate": null,
                                "lockable": true,
                                "semantic": "Erlaubnis zur Datenverarbeitung",
                                "description": "Datenverarbeitung"
                            },
                            "variant": "OPTIONAL",
                            "ordinalNumber": 1
                        }
                    ],
                    "purposes": [
                        {
                            "id": 3,
                            "purpose": {
                                "id": 2,
                                "name": "ANALYTICS",
                                "lockDate": null
                            },
                            "validityInDays": 9999
                        }
                    ],
                    "reference": null,
                    "textPrimary": "Usage Definition1",
                    "legalEntities": [
                        {
                            "id": 1,
                            "name": "BMW_AG",
                            "country": null,
                            "lockDate": null,
                            "outletId": null,
                            "dealerNumber": null
                        }
                    ],
                    "textSecondary": null
                }
            ]
        }
    ],
    "description": "For Carmen Testing Pruposes",
    "primaryText": null,
    "majorVersion": 1,
    "minorVersion": 0,
    "secondaryText": null,
    "dataController": null,
    "encodedPolicyDocuments": []
}

例如,如果我需要在“使用情况”下提取“名称”字段的值=>“名称”:“数据处理” 我怎样才能做到这一点 ?我尝试使用jsonb_array_elements,但无法提取此类参数。

预先感谢您的所有建议。

最诚挚的问候

丹尼尔

0 个答案:

没有答案
相关问题