I have an API that returns a JSON object that will be displayed in a UI. The order of the fields in the object matters because the UI wants to display the fields in that order. I want to write a unit test to ensure the order of the fields in the object is correct. My API response looks like this:
{
"data": {
"field1": "value1",
"field2": "value2"
}
}
Using spring boot's MockMvc
library, I want to write an expression like this to validate that the fields are coming back in order:
.andExpect(jsonPath("$.data"), is("field1=value1, field2=value2")
Obviously, the above doesn't work but I'm not sure what type of Matcher
I should be using to try and validate that the fields are in order.