0

If I have a JSON like so:

{
  "data": [
    {
        "service" : { "id" : 1 }
    },
    {
        "service" : { "id" : 2 }
    },
    {
        "service" : {}
    }
  ]
}

This query works:

$..service[?(@.id==2)]

And gives expected result:

[
    {
        "id" : 2
    }
] 

However, if I had strings as id's:

{
  "data": [
    {
        "service" : { "id" : "a" }
    },
    {
        "service" : { "id" : "b" }
    },
    {
        "service" : {}
    }
  ]
}

Running similar query:

$..service[?(@.id == "a")]

Gives no results (empty array).
I am using this evaluator.
I was looking at docs here but could not find anything to point me in the right direction... Any help if someone knows how to write such query? Thanks :)

1 Answer 1

1

without " works

$..service[?(@.id == b)]

give this result

[
   {
      "id" : "b"
   }
]
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.