Class JsonValues

java.lang.Object
com.babelqueue.JsonValues

public final class JsonValues extends Object
Canonical encode/decode for a single decoded-JSON value, using the same minimal codec the wire envelope uses. It is the seam field-level features (com.babelqueue.gdpr) need: the core's Json reader/writer is package-private (it must never force a JSON library on consumers, GR-7), so this class exposes just enough of it — one value in, one value out — without widening Json itself.

Because it routes through the very same codec, the round-trip is type-exact: a value decoded by EnvelopeCodec.decode(java.lang.String) (numbers as Long/BigInteger/ Double, objects as LinkedHashMap, arrays as ArrayList) re-encodes and re-decodes back to the same Java types. That is what lets protect/unprotect restore a protected field byte-for-byte after a decrypt.

  • Method Summary

    Modifier and Type
    Method
    Description
    static Object
    Parse one JSON document back into a decoded-JSON value, with the same types the envelope codec produces.
    static String
    encode(Object value)
    Encode one decoded-JSON value to its compact canonical JSON string — the same form the envelope codec emits (slashes and non-ASCII left literal, no insignificant whitespace).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • encode

      public static String encode(Object value)
      Encode one decoded-JSON value to its compact canonical JSON string — the same form the envelope codec emits (slashes and non-ASCII left literal, no insignificant whitespace).
      Parameters:
      value - a decoded-JSON value (Map/List/String/Number/ Boolean/null)
      Returns:
      the compact JSON encoding
      Throws:
      BabelQueueException - if the value cannot be encoded (e.g. a non-finite number)
    • decode

      public static Object decode(String raw)
      Parse one JSON document back into a decoded-JSON value, with the same types the envelope codec produces. The exact inverse of encode(Object).
      Parameters:
      raw - a JSON document holding a single value
      Returns:
      the decoded value
      Throws:
      BabelQueueException - if raw is not a single, well-formed JSON value