Search code examples
jsonpath

$.concat function doesn't work with filter in jayway implementation of jsonPath


I'm trying to apply the jsonPath expression:

"$.concat($.[?(@.channel=='one' && 
@.stream=='test')].air.track.author," - ",$.[?(@.channel=='one' &&
@.stream=='test')].air.track.title)"

To JSON:

[
  {
    "channel": "one",
    "stream": "test",
    "air": {
      "track": {
        "author": "Jack",
        "title": "book1"
      }
    }
  },
  {
    "channel": "one",
    "stream": "prod",
    "air": {
      "track": {
        "author": "Alex",
        "title": "book2"
      }
    }
  }
]

And am getting the error:

*"Could not parse token starting at position 2. Expected ?, ', 0-9, "

But when I try with:

"$.concat($.[0].air.track.author," - ",$.[0].air.track.title)"

The result is: "Jack - book1"

Why is it producing an error when $.concat is called using filter?

https://jsonpath.herokuapp.com/


Solution

  • Issue resolved in version 2.5.0: https://github.com/json-path/JsonPath/issues/620