Class JsonContentHash

java.lang.Object
io.ebeaninternal.server.util.JsonContentHash

public final class JsonContentHash extends Object
Compute an order-independent structural hash of JSON content using Jackson's streaming parser.

Object key ordering does NOT affect the hash value (handles PostgreSQL JSONB key reordering), while array element ordering DOES affect it (array position is semantically significant).

This is significantly faster than a full parse/format roundtrip because it performs zero object allocation beyond the parser itself — no tree building, no reflection, no type conversion. Single-pass O(n) time with O(depth) stack space.

  • Constructor Details

    • JsonContentHash

      public JsonContentHash()
  • Method Details

    • hash

      public static long hash(String json)
      Compute an order-independent hash of JSON content. Two JSON strings with identical content but different key ordering will produce the same hash value.