As it turns out Jackson does not do stable JSON object comparison contrary to this question. So I was wondering if GSON has stable comparison of JSON objects. (without having to override equals/implement one's own comparator)
Asked
Active
Viewed 196 times
1 Answers
2
Your gist shows org.json code, not Jackson.
Jackson has a perfectly able .equals() implementation for all JsonNode
s. And that includes all "non container types" as well as "container types":
final JsonNodeFactory factory = JsonNodeFactory.instance;
final JsonNode node1 = factory.objectNode().put("hello", "world");
final JsonNode node2 = factory.objectNode().put("hello", "world");
node1.equals(node2); // true
Of course, it does respect JSON's "order does not matter" with object members: { "a": 1, "b": 2 }
is equal to { "b": 2, "a": 1 }
-- as it should.
That may only be my opinion as well, but really, when it comes to JSON, anything is better than org.json.

fge
- 119,121
- 33
- 254
- 329
-
plus[1] for the order doesnt matter mention! – Gaurav Feb 14 '19 at 12:45