Documentation ¶
Overview ¶
Package cjson canonicalizes JSON. This package implements the canonicalization rules defined in https://github.com/olympos-labs/cjson/blob/master/SPEC.md and provides utility functions around converting both existing and new data to canonical JSON.
In addition, the package contains a small command line tool named json_canonicalize. It can be installed by calling
go get olympos.io/encoding/cjson/cmd/json_canonicalize
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Canonicalize ¶
Canonicalize canonicalizes JSON values from src and puts the result into dst. Multiple values from src will be separated by a space only if necessary.
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder writes canonical JSON values to an output stream.
func NewEncoder ¶
NewEncoder returns a new encoder that writes to w.
func (*Encoder) Encode ¶
Encode writes the JSON encoding of v to the stream. If multiple values are encoded, they will be separated by a space if necessary if StreamSpace is enabled (default on).
See the documentation for encoding/json.Marshal for details about the conversion of Go values to JSON.
func (*Encoder) SetStreamSpace ¶
SetStreamSpace turns spaces between values that must be separated on or off.
You should typically not modify this unless you manually manage stream separation.