← All procedures

generators.canonicalJson

This function gives the canonical form of a value. The default form is RFC 8785 (JCS):

CLI
Package
@procedures/generators · README
Path
["generators","canonicalJson"]
CLI
mark generators canonicalJson --value <any>
As data
{"$proc":["generators","canonicalJson"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/generators/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["generators","canonicalJson"], { value: "<value>" });
console.log(JSON.stringify(result));

From the command line

$ mark generators canonicalJson --value <any>

As data, in a program

{
  "$proc": ["generators", "canonicalJson"],
  "input": { "value": "<value>" }
}

Input

FieldTypeRequiredDefaultDescription
valueanyyes
optionsobjectno

Output

The schema does not list fields (string).

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "value": {},
      "options": {
        "type": "object",
        "properties": {
          "form": {
            "type": "string",
            "enum": [
              "jcs",
              "json"
            ],
            "description": "The form of the values that JSON does not have:"
          },
          "bigint": {
            "type": "string",
            "enum": [
              "error",
              "suffix"
            ],
            "description": "The form of a `bigint`. `\"error\"` (the default) causes a `TypeError`, as `JSON.stringify` does. `\"suffix\"` writes the digits and the letter `n`, for example `12n`. This text is not JSON, so use it only for a key."
          },
          "tags": {
            "type": "string",
            "enum": [
              "none",
              "typed"
            ],
            "description": "The form of a `Date`, a `RegExp`, a `Map`, a `Set` and a `bigint`:"
          }
        },
        "additionalProperties": {}
      }
    },
    "required": [
      "value"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "string"
  }
}