Package com.babelqueue
Class JsonValues
java.lang.Object
com.babelqueue.JsonValues
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 TypeMethodDescriptionstatic ObjectParse one JSON document back into a decoded-JSON value, with the same types the envelope codec produces.static StringEncode 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).
-
Method Details
-
encode
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
Parse one JSON document back into a decoded-JSON value, with the same types the envelope codec produces. The exact inverse ofencode(Object).- Parameters:
raw- a JSON document holding a single value- Returns:
- the decoded value
- Throws:
BabelQueueException- ifrawis not a single, well-formed JSON value
-