2

I have a sample JSON array:

{
"data": {
    "list": [
        {
            "id": 192,
            "name": "John Black",
            "username": "jblack",
            "email": "[email protected]",
            "extern_uid": "user distinguished name"
        },
        {
            "id": 63,
            "name": "Jane Doe",
            "username": "jadoe",
            "email": "[email protected]",
            "extern_uid": "user distinguished name"
        }
    ]
}}

I want to extract an attribute based on another attribute using JSONPath expression,

For example:

I want to search for the name "Jane Doe" and extract values from the Jane Doe array like id: 63 or any other value in the Jane Doe array. Is this possible in JSONPath? I am not an expert in JSONPath so I apologize if this may seem trivial for others

Thanks all

1 Answer 1

3

I have found a solution:

$.data.list[?(@.username == "jblack")].id

This will return:

"id": 192
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.