io.setl.json.package-info Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of canonical-json Show documentation
Show all versions of canonical-json Show documentation
An implementation of the Canonical JSON format with support for javax.json and Jackson
The newest version!
/**
* This package implements the creation and verification of canonical JSON.
*
* The definition of canonical JSON was taken from the canonicaljson
* project. The definition is reproduced below for convenience.
*
* Definition
*
* JSON text in canonical form:
*
* - MUST be encoded in UTF-8
* - MUST NOT include insignificant (i.e., inter-token) whitespace (defined in section 2 of
* RFC 7159)
* - MUST order the members of all objects lexicographically by the UCS (Unicode Character Set) code points of their names
*
* - preserving and utilizing the code points in U+D800 through U+DFFF (inclusive) for all lone surrogates
*
*
* - MUST represent all integer numbers (those with a zero-valued fractional part)
*
* - If the integer number has thirty or less trailing zeros:
*
* - without a leading minus sign when the value is zero, and
* - without a decimal point, and
* - without an exponent, and
* - without insignificant leading zeroes (as already required of all JSON numbers)
*
*
* - If the integer number has more than thirty trailing zeroes, use the rules for non-integer numbers. This prevents attacks by using values such as
* "1e+1000000", which would otherwise require a million zeros.
*
*
* - MUST represent all non-integer numbers in exponential notation
*
* - including a nonzero single-digit significand integer part, and
* - including a nonempty significand fractional part, and
* - including no trailing zeroes in the significand fractional part (other than as part of a “.0” required to satisfy the preceding point), and
* - including a capital “E”, and
* - including no plus sign in the exponent, and
* - including no insignificant leading zeroes in the exponent
*
*
* - MUST represent all strings (including object member names) in their minimal-length UTF-8 encoding
*
* - avoiding escape sequences for characters except those otherwise inexpressible in JSON (U+0022 QUOTATION MARK, U+005C REVERSE SOLIDUS, and ASCII
* control characters U+0000 through U+001F) or UTF-8 (U+D800 through U+DFFF), and
* - avoiding escape sequences for combining characters, variation selectors, and other code points that affect preceding characters, and
* - using two-character escape sequences where possible for characters that require escaping:
*
* \b
U+0008 BACKSPACE
* \t
U+0009 CHARACTER TABULATION (“tab”)
* \n
U+000A LINE FEED (“newline”)
* \f
U+000C FORM FEED
* \r
U+000D CARRIAGE RETURN
* \"
U+0022 QUOTATION MARK
* \\
U+005C REVERSE SOLIDUS (“backslash”), and
*
*
* - using six-character
\u00xx
uppercase hexadecimal escape sequences for control characters that require escaping but lack a
* two-character sequence, and
* - using six-character
\uDxxx
uppercase hexadecimal escape sequences for lone surrogates
*
*
*
*
* @author Dr Simon Greatrix
*/
package io.setl.json;
© 2015 - 2025 Weber Informatics LLC | Privacy Policy