【问题标题】:jsonpath find all object(restassured)jsonpath 找到所有对象(放心)
【发布时间】:2014-07-31 14:28:08
【问题描述】:

这是我的 JSON:

[
{
    "id": 9741962,
    "name": "getName",
    "isActive": true
},
{
    "id": 1,
    "name": "New",
    "isActive": true
}
]

我想使用 jsonPath 获取所有名称为 :getName 的对象 用JsonPath怎么办(放心自带的onw)

我试试这个

JsonPath.with(jsonResponse).get("findAll { a -> a.name == getName  }");

但我收到错误消息。

java.lang.IllegalArgumentException: No such property: sdfsdf for class: Script1

谢谢。

【问题讨论】:

    标签: java rest-assured rest-assured-jsonpath


    【解决方案1】:

    好的,我找到了,需要加撇号。

    JsonPath.with(jsonResponse).get("findAll { a -> a.name == 'getName' }");

    【讨论】:

      【解决方案2】:

      您需要设置参数。试试

      JsonPath.with(jsonResponse).param("name", "getName").get("findAll { a -> a.name == name  }")
      

      【讨论】:

      • 该参数仅适用于版本 2.3.2
      • 你用的是哪个版本?
      • 我们有 reassured 和 jsonPath 的 2.3.1 版本。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多