0

From the contacts, I'd like to select the values in fields: "Id" (47) and everything from the nested array [doNotContact]. I could use some help defining the JSONPath-filter I should be using to select the values: 47 and each value inside the nested array.

{
    "total": "1",
    "contacts": {
        "47": {
            "id": 47,
            "isPublished": true,
            "dateAdded": "2015-07-21T12:27:12-05:00",
            "createdBy": 1,
            "createdByUser": "Joe Smith",
            "doNotContact": [{
                "id": 2,
                "reason": 2,
                "comments": "",
                "channel": "email",
                "channelId": null
            }]
        }
    }
}

I have tried paths like: $.contacts.*.['id','doNotContact'] however, this does not seem to work. I am using the website: https://goessner.net/articles/JsonPath/ normally this would help me solve the problem.

gregsdennis
  • 7,218
  • 3
  • 38
  • 71
Marijn
  • 1

1 Answers1

0

Not all implementations support the comma-delimited selectors, e.g. ['id','doNotContact']. See the JSON Path comparison project site (specifically this test) for information as to which implementations support the syntax.

Secondly, please see this answer about omitting the dot before a bracket syntax

gregsdennis
  • 7,218
  • 3
  • 38
  • 71