Skip to content

std/encoding/json/jcs

import "github.com/eugenioenko/goalchemy/std/encoding/json/jcs"

Package jcs implements the JSON Canonicalization Scheme of RFC 8785. Transform parses JSON text and returns its canonical encoding: object members sorted by the UTF-16 code units of their names, no insignificant whitespace, strings with only the escapes RFC 8785 requires, and numbers written as ECMAScript’s Number::toString writes them. Invalid JSON, duplicate member names, and numbers that are not finite doubles are errors.

func Encode(v jsonvalue.Value) ([]byte, error)

Encode returns the RFC 8785 canonical encoding of v. Numbers are read from their source text; a number outside the finite double range is a NumberError.

func Transform(data []byte) ([]byte, error)

Transform returns the RFC 8785 canonical encoding of the JSON text data, parsed with jsonvalue.DefaultLimits.

func TransformWithLimits(data []byte, l jsonvalue.Limits) ([]byte, error)

TransformWithLimits is Transform with explicit parsing limits.

type NumberError struct {
Text string
}

NumberError reports a JSON number that has no finite IEEE 754 double.

func (e *NumberError) Error() string