我正在使用空手道自动化工具进行服务自动化.. 我正在尝试从我存储在变量中的 json 响应中提取部门 ID...
def departmentId = getstorewalk.departments[*].id
getstorewalk 是我存储 json 响应的变量
以下是json响应
{"walkzz":"001","zz":zz,"ddd":"zz","zz":{"zz":"zz","who":{"zz":"11"," zz":"zz"}},"departments":[{"id":需要提取这个id,"name":"zz","someorder":1,"zzs":[{"zz":zz ,"name":"zz (zz, zz, zz, zz & zz)","someorder":zz,"zz":[{"zz":51,"name":"zz Spread","someorder" :16,"zz":"可用","zz":[{"zz":"1223","zz":"zz 30g","zz":3,"zz":0,"zz": "陈旧","zz":false,"zz":true,"zz":[],"zz":{"zz":2,"zz":"zz","zz":6,"zzName":"核心 zz (zz)","department":56,"zz":"015 zz Spreads","zz":"zz Spread","subzz":100," somezz":"zz & zz","zz":{},"zz_":100},"zz":{"zz":"2017-09-21T11:09:15.524Z","who":{ "zz":"11","zz":"zz"}},"action":{"zz":"Include"},"zz":[{"capturezz":375716,"zz":"差距","qty":15,"zz":"zz","zz":{"zz":"zz","type":"N","name":"zz","sequence":1 },"zz":{"zz":"211","who":{"zz":"11","zz":"zz"}}}]}]}]}]}]}
我在后台使用了以下内容:
- def getstorewalk = callonce read('classpath:zz/zz/zz.feature')
- def departmentId = getstorewalk.departments[*].id
下面列出了错误:com.jayway.jsonpath.PathNotFoundException:com.jayway 的 com.jayway.jsonpath.internal.path.PathToken.handleObjectProperty(PathToken.java:72) 的路径 $['departments'] 中缺少属性。 jsonpath.internal.path.PropertyPathToken.evaluate(PropertyPathToken.java:77) 在 com.jayway.jsonpath.internal.path.RootPathToken.evaluate(RootPathToken.java:62) 在 com.jayway.jsonpath.internal.path.CompiledPath。在 com.jayway.jsonpath.internal.path.CompiledPath.evaluate(CompiledPath.java:61) 在 com.jayway.jsonpath.JsonPath.read(JsonPath.java:187) 在 com.jayway 评估(CompiledPath.java:53) .jsonpath.internal.JsonContext.read(JsonContext.java:164) 在 com.jayway.jsonpath.internal.JsonContext.read(JsonContext.java:151) 在 com.intuit.karate.Script.evalJsonPathOnVarByName(Script.java:339 ) 在 com.intuit.karate.Script.eval(Script.java:262) 在 com.intuit.karate.Script.eval(Script.java:182) 在 com.intuit.karate.Script.assign(Script.java:606) 在 com .intuit.karate.Script.assign(Script.java:537) at com.intuit.karate.StepDefs.def(StepDefs.java:268) at ?.* def departmentId = getstorewalk.departments[*].id(C: /空手道/zz/zz/src/test/java/zz/zz/zz.feature:11)