$ .concat函数不适用于jsonPath的jayway实现中的过滤器

时间:2020-10-08 14:50:00

标签: jsonpath

我正在尝试应用jsonPath表达式:

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

至JSON:

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

并收到错误消息:

* “无法分析从位置2开始的令牌。预期为?,',0-9,

但是当我尝试:

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

结果是:“杰克-book1”

为什么使用过滤器调用$ .concat时会产生错误?

https://jsonpath.herokuapp.com/

1 个答案:

答案 0 :(得分:0)

在 2.5.0 版本中解决的问题: https://github.com/json-path/JsonPath/issues/620