The input data looks as follows.
[
{
"mahKey": "mahString.yolo",
"mahValue": "0"
},
{
"mahKey": "notMahString.crymeariver",
"mahValue": "1"
},
{
"mahKey": "mahSTring.omg",
"mahValue": "2"
}
]
So I have this.
resultActions
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(jsonPath("$.*", isA(ArrayList.class)))
.andExpect(jsonPath("$.[mahKey]", Matchers.everyItem(Matchers.startsWith("mahString"))));
The array after $.[mahKey] looks like this.
[
"mahString.yolo",
"notMahString.crymeariver",
"mahSTring.omg"
]
However, I get the following error:
com.jayway.jsonpath.InvalidPathException: Could not parse token starting at position 3. Expected ?, ', 0-9, *
How to check whether all elements of a JSON array start with a specific string in JUnit?
