java - Comparing two JSONObject structures (ignoring their values)? -
i'm looking json paring library supports comparing 2 json objects' structures, ignoring values, child order, , - if possible - optionally ignoring additional elements in response; unit testing json returning web service against expected structure. (i'd pass assert method sample response , compare structure actual response - instead of having write asserts each node. getting different values isn't problem, long structure fine.)
do of major json libraries support this? (this question same compare 2 json objects in java, want assert ignore values in json structure, might example found on wikipedia...)
you may want have @ guava , equivalence
.
if instance use jackson, write equivalence<jsonnode>
, customize needs.
here example of such equivalence
, considers 2 json values equal if numbers, recursively, mathematically equal.
usage: yourequivalence.equivalent(node1, node2)
.
another solution write pojo serializes json want , attempt deserialize json said pojo. if deserialization fails structure wrong.
Comments
Post a Comment