【问题标题】:I want to know how to get Test1 value using Jsonpath我想知道如何使用 Jsonpath 获取 Test1 值
【发布时间】:2022-01-03 11:41:33
【问题描述】:

我想知道“createdTs”值大于等于444的“Test1”的值。

[
   {
"raw" : {
      "Test1":"Apple",
      "Test2":{
            "createdTs": 333,
            "langCode": "ko"
        }
    }
},
    {
"raw" : {
      "Test1":"Tomato",
      "Test2":{
            "createdTs": 555,
            "langCode": "ko"
        }
    }
}
]

即使我如下所示调用Jsonpath,它也不起作用。

$[?(@.['Test2'].createdTs > 444)]

我想要的结果如下。

"raw" : {
      "Test1":"Tomato",
      "Test2":{
            "createdTs": 555,
            "langCode": "ko"
        }
    }

【问题讨论】:

标签: jsonpath json-path-expression


【解决方案1】:

要访问路径,您需要指定从父节点到子节点的所有属性。

$[?(@.raw.Test2.createdTs > 444)]

请完整阅读文档以了解和了解 jayway jsonpath 的工作原理。 https://github.com/json-path/JsonPath#getting-started

在线测试工具:https://jsonpath.herokuapp.com/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多