JSON Formatter

Overview

A JSON Formatter formats a JSON input message according to certain criteria and provides the formatted result as a JSON output message.

The input message must be valid JSON; otherwise, the plugin will fail to read the input. An input message must be provided, as the plugin cannot process an empty message.

JSON Canonicalization Scheme (JCS)

The JSON Formatter converts the JSON input into the canonical format by default.

The formatter ensures that the JSON data is structured consistently and standardized, making it reliable for comparison, signing, storage, or transmission.

The JCS specification defines how to create a canonical representation of JSON. The output from JCS is a "hashable" representation of JSON data that cryptographic methods can use.

In addition, two JSON messages can be compared safely when formatted into JCS. They will be identical if they contain the same structure, keys and values.

Another advantage of a canonicalizing scheme is that data can be kept in its original form. This is the core rationale behind JCS. In other words, canonicalization enables a JSON object to maintain its integrity even after being signed. This can simplify system design, documentation, and logging, making the process more efficient and streamlined.

Example for JSON Formatter: Input and Output Messages

Input message

{
  "numbers": [333333333.33333329, 1E30, 4.50, 2e-3, 0.000000000000000000000000001],
  "string": "\u20ac$\u000F\u000aA'\u0042\u0022\u005c\\\"\/",
  "literals": [null, true, false]
}

Output Message

{
  "literals":[null,true,false],"numbers":[333333333.3333333,1e+30,4.5,0.002,1e-27],"string":"€$\u000f\nA'B\"\\\\\"/"
}