首页 > 解决方案 > 如何在 jsonpath 中获取条件

问题描述

拥有 json,请提供以下内容:

[
  {
    "delta": {
      "status": {
        "old": {
          "status": "Stop"
        },
        "new": {
          "status": "Start"
        }
      }
    }
  }
]

我怎样才能只获得具有 new.status = 'Start' 的增量?

我尝试使用 Apache 骆驼choice().when().jsonpath(...)

为什么下面的语句不起作用?

$..[?(@.delta.status.new.status=='Start')]
$..delta.status.new[?(@.status=='Start')]

我用过 jsonpath.com

标签: jsonapache-cameljsonpath

解决方案


您的陈述还可以,我已经使用jsonpath.herokuapp和骆驼jsonpath组件对其进行了测试,例如第二个返回{status: Start}


推荐阅读