Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AssertJ JSON property check

I have JSONObject instance which contains some property,

{
"name":"testName",
"age":"23"
}

i use the following assert, but it fails. Is this correct approach to test JSON in assertj.

assertThat(jsonObject).hasFieldOrProperty("name");
like image 363
parrotjack Avatar asked Dec 31 '22 08:12

parrotjack


1 Answers

If you want to do any serious assertions on JSON object, I would recommend JsonUnit https://github.com/lukas-krecan/JsonUnit

like image 191
Joel Costigliola Avatar answered Jan 08 '23 19:01

Joel Costigliola