问题描述
当我尝试https://jsonpath.com/中的$。[?(@。userId =='1')]。title时,得到了预期的结果。但是当我在代码中使用相同的表达式时,会出错。
@Test
public void restPost2(){
RestAssured.baseURI = "https://jsonplaceholder.typicode.com/posts";
RequestSpecification req = RestAssured.given().log().all();
String res1 = req.given().when().get().then().extract().asString();
JsonPath js = new JsonPath(res1);
System.out.println("specific title : " + js.get("$.[?(@.userId == '1')].title"));
}
任何人都可以指导为什么我的代码抛出以下错误:
java.lang.IllegalArgumentException: Invalid JSON expression:
Script1.groovy: 1: unexpected token: [ @ line 1,column 29.
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)