【发布时间】:2022-01-03 00:06:55
【问题描述】:
我正在尝试使用 JSON 表达式检索具有 "type":"system" 的工作流的 ID
方法:
public static int getSystemWorkflowId(final Map<String, String> cookies) {
return workflow.get(cookies).then().extract().jsonPath().getInt("$..workflows[?(@.type =='system')].id");
}
有效载荷
{
"workflows": [
{
"id": 1,
"name": "Recruitment workflow",
"type": "system",
"options": [
],
"active": 1
},
{
"id": 3,
"name": "TestWorkflow",
"options": [
],
"active": 1
}
]
}
错误:
java.lang.IllegalArgumentException:无效的 JSON 表达式: Script1.groovy:1:意外输入:'['@ 第 1 行,第 39 列。 $..workflows[?(@.type =='system')].id
我已经在在线评估器中测试了该表达式,它似乎有效...enter image description here
谢谢!
【问题讨论】:
标签: rest-assured jsonpath rest-assured-jsonpath json-path-expression