如何在Json

时间:2015-05-09 11:06:00

标签: json

我想从Json Payload中选择'Code'元素的第一个值。我正在使用以下网站试试这个。 http://jsonpath.curiousconcept.com/

Json Payload:

   {
    "TotalAccounts": {
        "Account": [
            {
                "Code": 123,
                "Account": {
                    "Name": {
                        "Initials": null
                    },
                    "Address": {
                        "Street": "ABC"
                    }
                },
                "ContactInformation": {
                    "Email": "ABC@gmail.com"
                },
                "DunningLevelCode": "R0"
            },
            {
                "Code": 456,
                "Account": {
                    "Name": {
                        "Initials": null
                    },
                    "Address": {},
                    "CustomFields": null
                },
                "ContactInformation": {
                    "Email": "ABC@@gmail.com",
                    "Phone": null,
                    "Mobile": null,
                    "Fax": null
                },
                "DunningLevelCode": "abc"
            }
        ]
    }
}

我正在使用的Json路径如下:

$..Code

结果:

[123,456]

预期结果:

[123]

需要帮助。

1 个答案:

答案 0 :(得分:1)

使用此功能,您将获得输出

$..Account[0].Code