json

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package json wraps encoding/json as a codec.Codec implementation registered under Format("json"). Blank-importing this package is enough to make JSON resolvable via the core/codec registry.

Package json — range 0.3.2.* (ADR 0005 service/codec/json block).

Package json — adapts *encoding/json.Decoder to codec.Decoder.

Package json — adapts *encoding/json.Encoder to codec.Encoder.

Package json — declares the sentinel *errs.Error values used to wrap failures from encoding/json.

Index

Constants

View Source
const CodeJSONMarshalFailed errs.Code = 0x00_03_02_01 // 0.3.2.1

CodeJSONMarshalFailed identifies a failure inside encoding/json.Marshal.

View Source
const CodeJSONUnmarshalFailed errs.Code = 0x00_03_02_02 // 0.3.2.2

CodeJSONUnmarshalFailed identifies a failure inside encoding/json.Unmarshal.

Variables

View Source
var (
	// MarshalFailed wraps a failure from encoding/json.Marshal.
	MarshalFailed = errs.Define(CodeJSONMarshalFailed, "MARSHAL_FAILED",
		"JSON encoding failed",
		"service/codec/json: encoding/json.Marshal returned an error")

	// UnmarshalFailed wraps a failure from encoding/json.Unmarshal.
	UnmarshalFailed = errs.Define(CodeJSONUnmarshalFailed, "UNMARSHAL_FAILED",
		"JSON decoding failed",
		"service/codec/json: encoding/json.Unmarshal returned an error")
)
View Source
var Codec codec.Codec = codec.Register(&jsonCodec{})

Codec is the JSON singleton, registered with core/codec at package load. Binding the registration result to a named var is more idiomatic than `var _ = codec.Register(...)` and keeps us clear of init().

Functions

func New

func New() codec.Codec

New returns the JSON codec singleton.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL