我正在使用MockMvc来测试返回 JSON 内容的 API,并且该 JSON 可能包含一个名为“ shares”的字段作为空数组,或者可能根本不存在(我的意思是“ shares”字段)。
JSON 示例:
{
"id":1234,
.....
"shares":[]
}
//or
{
"id":1234,
....
}
我如何断言此字段为空或不存在
喜欢:
mvc.perform(
post("....url.......")
.andExpect(status().is(200))
// I need one of the following to be true, but this code will assert both of them, so it will fail
.andExpect(jsonPath("$.shares").isEmpty())
.andExpect(jsonPath("$.shares").doesNotExist())
扬帆大鱼
					江户川乱折腾
					杨__羊羊
					倚天杖
					料青山看我应如是
随时随地看视频慕课网APP
相关分类