jsonpath 查找所有对象(放心) [英] jsonpath find all object(restassured)
本文介绍了jsonpath 查找所有对象(放心)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的 JSON :
<预><代码>[{身份证":9741962,"name": "getName",isActive":真},{身份证":1,"name": "新",isActive":真}]我想使用 jsonPath 获取所有名称为 :getName 的对象我如何使用 JsonPath 来做到这一点(放心的 onw)
我试试这个
JsonPath.with(jsonResponse).get("findAll { a -> a.name == getName }");
但我收到错误消息.
java.lang.IllegalArgumentException:没有这样的属性:类的 sdfsdf:Script1
谢谢.
解决方案
好的我找到了,需要添加撇号.
JsonPath.with(jsonResponse).get("findAll { a -> a.name == 'getName' }");
This is my JSON :
[
{
"id": 9741962,
"name": "getName",
"isActive": true
},
{
"id": 1,
"name": "New",
"isActive": true
}
]
I want to get all the object that has the name :getName using jsonPath how can I do it using JsonPath (the onw that comes with rest assured)
I try this one
JsonPath.with(jsonResponse).get("findAll { a -> a.name == getName }");
but I am getting Error.
java.lang.IllegalArgumentException: No such property: sdfsdf for class: Script1
Thanks.
解决方案
OK I found it, needed to add apostrophes.
JsonPath.with(jsonResponse).get("findAll { a -> a.name == 'getName' }");
这篇关于jsonpath 查找所有对象(放心)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文