Documentation ¶
Overview ¶
Package json implements the JSON-Cadence specification: https://github.com/onflow/flow/blob/master/docs/json-cadence-spec.md
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidJSONCadence = errors.NewDefaultUserError("invalid JSON Cadence structure")
Functions ¶
func Decode ¶
Decode returns a Cadence value decoded from its JSON-encoded representation.
This function returns an error if the bytes represent JSON that is malformed or does not conform to the JSON Cadence specification.
func Encode ¶
Encode returns the JSON-encoded representation of the given value.
This function returns an error if the Cadence value cannot be represented as JSON.
func MustEncode ¶ added in v0.2.0
MustEncode returns the JSON-encoded representation of the given value, or panics if the value cannot be represented as JSON.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder decodes JSON-encoded representations of Cadence values.
func NewDecoder ¶
func NewDecoder(gauge common.MemoryGauge, r io.Reader) *Decoder
NewDecoder initializes a Decoder that will decode JSON-encoded bytes from the given io.Reader.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder converts Cadence values into JSON-encoded bytes.
func NewEncoder ¶
NewEncoder initializes an Encoder that will write JSON-encoded bytes to the given io.Writer.
type Option ¶ added in v0.24.4
type Option func(*Decoder)
func WithAllowUnstructuredStaticTypes ¶ added in v0.24.4
WithAllowUnstructuredStaticTypes returns a new Decoder Option which enables or disables if the decoding of a static type as a type ID (cadence.TypeID) is allowed