【发布时间】:2020-07-06 13:14:54
【问题描述】:
我正在使用非静态导入
JsonPath jp = response.jsonPath();
System.out.println(jp.get("data?(@.id>14).employee_name").toString());
对于如下所示的 JSON:
{"status":"success","data":[{"id":"1","employee_name":"Tiger Nixon","employee_salary":"320800","employee_age":"61","profile_image":""},{"id":"2","employee_name":"Garrett Winters","employee_salary":"170750","employee_age":"63","profile_image":""}]}
当我尝试运行它时,出现以下错误:
java.lang.IllegalArgumentException: Invalid JSON expression:
Script1.groovy: 1: expecting EOF, found '[' @ line 1, column 31.
data[?(@.id>14)].employee_name
^
1 error
谁能指导我为什么会抛出这个错误?
【问题讨论】:
-
Rest Assured 使用
GPath,这不是您可能知道的JSONPath。
标签: json api rest rest-assured rest-assured-jsonpath