samedi 9 mai 2015

How to Get the first value of same element in Json

I want to pick the first value of 'Code' element from following Json Payload. I am using following website to try this out. http://ift.tt/1auydud

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"
            }
        ]
    }
}

The Json path i am using is below:

$..Code

Result:

[123,456]

Expected Result:

[123]

Need help.

Aucun commentaire:

Enregistrer un commentaire