public final class JsonCanonicalizer extends Object
This class utilizes Jakarta
JSON Processing as input for canonicalization. The canonicalized JSON
output is written to a provided Writer.
Usage:
canonize(JsonValue, Writer)
| Constructor and Description |
|---|
JsonCanonicalizer() |
| Modifier and Type | Method and Description |
|---|---|
static String |
canonize(jakarta.json.JsonValue value)
Canonicalizes a JSON value according to the RFC 8785 JSON Canonicalization
Scheme (JCS) and returns the canonicalized JSON as a string.
|
static void |
canonize(jakarta.json.JsonValue value,
Writer writer)
Canonicalizes a JSON according to the RFC 8785 JSON Canonicalization Scheme
(JCS).
|
static void |
canonizeArray(jakarta.json.JsonArray value,
Writer writer)
Canonicalizes a JSON array according to the RFC 8785 JSON Canonicalization
Scheme (JCS).
|
static void |
canonizeNumber(jakarta.json.JsonNumber number,
Writer writer)
Canonicalizes a JSON number according to the RFC 8785 JSON Canonicalization
Scheme (JCS).
|
static String |
escape(String value)
Escapes special characters in a JSON property name according to JSON
canonicalization rules.
|
public static final String canonize(jakarta.json.JsonValue value)
This method serializes the given JsonValue in a deterministic and
standardized manner, ensuring a consistent output regardless of formatting
differences. It handles all JSON value types, including objects, arrays,
numbers, strings, and literals (true, false, null).
value - the JSON value to be canonicalizedpublic static final void canonize(jakarta.json.JsonValue value,
Writer writer)
throws IOException
This method serializes the given JsonValue in a deterministic and
standardized manner, ensuring a consistent output regardless of formatting
differences. The canonicalized JSON is written to the provided
Writer.
This method handles different JSON value types, including objects, arrays, numbers, strings, and literals (true, false, null).
value - the JSON value to be canonicalizedwriter - the writer to which the canonicalized JSON output is writtenIOException - if an I/O error occurs while writing to the writerpublic static final void canonizeNumber(jakarta.json.JsonNumber number,
Writer writer)
throws IOException
This method serializes the given JsonNumber in a deterministic and
standardized manner, ensuring a consistent numeric representation. The
canonicalized number is written to the provided Writer.
number - the JSON number to be canonicalizedwriter - the writer to which the canonicalized JSON output is writtenIOException - if an I/O error occurs while writing to the writerpublic static final void canonizeArray(jakarta.json.JsonArray value,
Writer writer)
throws IOException
This method serializes the given JsonArray in a deterministic and
standardized manner, ensuring a consistent output. The canonicalized JSON
array is written to the provided Writer.
value - the JSON array to be canonicalizedwriter - the writer to which the canonicalized JSON output is writtenIOException - if an I/O error occurs while writing to the writerpublic static final String escape(String value)
This method ensures that control characters and other necessary characters are properly escaped to maintain a valid and consistent JSON representation.
value - the JSON property name to escapeCopyright © 2020–2025. All rights reserved.