Class VariantOrder
The KIND decides first: BOOLEAN < NUMBER < STRING < OBJECT < ARRAY < JSON null
(with an array's undefined hole after the null, so [1,undefined] and [1,null]
stay unequal). Within a kind: false before true; numbers by VALUE whatever their
notation (10 after 9, 1 equal to 1.0 and 1e0), with
-Infinity below every finite number and NaN above Infinity; strings by their
code points ("10" before "9", "Z" before "a"); arrays element by
element in this same order, a prefix first ([] < [0,5] < [1] <
[1,2] < ["a"]); objects member by member over their keys in sorted order, where at
each position the LARGER key sorts first and equal keys compare their values, a prefix first
({} < {"b":0} < {"a":0} < {"a":0,"c":0} <
{"a":0,"b":0} < {"a":0,"b":1} < {"a":1,"b":0}); a JSON null equals a
JSON null. Equality is this comparison answering zero, so {"a":1,"b":2} equals
{"b":2,"a":1} and [1] equals [1.0], while a variant STRING never equals the
number or object it spells.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intcompare(tools.jackson.databind.JsonNode left, tools.jackson.databind.JsonNode right) Orders two members.static StringcomparisonKey(tools.jackson.databind.JsonNode node) A text that is the same for two members exactly whencompare(tools.jackson.databind.JsonNode, tools.jackson.databind.JsonNode)answers zero — the key equality and hashing use, so a DISTINCT, a GROUP BY or a set operation sees1and1.0as one value and{"a":1,"b":2}and{"b":2,"a":1}as one object.
-
Method Details
-
compare
public static int compare(tools.jackson.databind.JsonNode left, tools.jackson.databind.JsonNode right) Orders two members.- Parameters:
left- one member, null read as a JSON nullright- the other- Returns:
- negative, zero or positive
-
comparisonKey
A text that is the same for two members exactly whencompare(tools.jackson.databind.JsonNode, tools.jackson.databind.JsonNode)answers zero — the key equality and hashing use, so a DISTINCT, a GROUP BY or a set operation sees1and1.0as one value and{"a":1,"b":2}and{"b":2,"a":1}as one object.- Parameters:
node- the member- Returns:
- its key
-