我正在尝试使用 Jsonpath 验证以下 json。我无法验证“fieldMap”之后的任何值。我尝试的所有内容都没有 JSON 路径错误。请告知如何验证 json 字符串。
{
"Identifier": "ABC#SOMEYNC001#112#2018071900:00",
"someEventId": "Some001",
"Error": null,
"fieldMap": {
"responseKey [someType=APPLICANT, somebaseid=982465, somechildid=Some001]": {
"Gur.CalledFlag": "Y",
"Some.SomeField01": "null",
"Some.SomeField02": "null",
"Some.SomeField03": "null",
"Some.SomeField04": "null",
},
"responseKey [someType=APPLICANT, somebaseid=982455, somechildid=Some001]": {
"Gur.CalledFlag": "Y",
"Some.SomeField01": "null",
"Some.SomeField02": "null",
"Some.SomeField03": "null",
"Some.SomeField04": "null",
}
},
"someMap": {
"982465": {
"urlMap": "http://someurl.com"
},
"982455": {
"urlMap": "http://someurl.com"
}
}
}
这就是我尝试验证的方式,但我失败了。
this.mockMvc
.perform(get("/v1.0/someapi/ABC/{SomeEventId}",
"Some001",
.andExpect(status().isOk())
.andExpect(jsonPath("$.Identifier").value(notNullValue()))
.andExpect(jsonPath("$.someEventId").value("Some001")))
//.andDo(MockMvcResultHandlers.print())
.andExpect(jsonPath("Error").value(nullValue()));
//.andExpect(jsonPath("$.fieldMap").value(nullValue()))
//.andExpect(jsonPath("$..[Gur.CalledFlag]").value(nullValue()));
我是这方面的新手,非常感谢任何帮助!