json

package
v0.19.7 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 3 Imported by: 0

README

json

import "github.com/kitsunium/sdk/pkg/v1/data/codec/json"

Package json registers the JSON codec with the SDK's codec registry — and no other codec — when it is imported (ADR 0134):

import _ "github.com/kitsunium/sdk/pkg/v1/data/codec/json"

Everything that dispatches through the registry by format name then reads and writes JSON: config.FileSource and config.FSSource, i18n.LoadFS, and the codec package's Marshal and Unmarshal. Importing github.com/kitsunium/sdk/pkg/v1/data/codec instead registers every format the SDK ships — BSON, CBOR, MessagePack and the rest — which a program that only reads JSON does not need to link. This package links the JSON codec, the core package declaring its codes and the standard library's encoding/json, and nothing else.

Importing both packages is harmless: a format is registered by the package that implements it, which Go initialises once however many packages import it.

Errors

Failures carry the range 0.3.2.*; match them with errs.HasCode, or the sentinels with errors.Is:

CodeMarshalFailed    0.3.2.1  encoding/json could not encode the value
CodeUnmarshalFailed  0.3.2.2  the input is not JSON the target can hold

Index

Constants

const CodeMarshalFailed errs.Code = 197121

CodeMarshalFailed identifies a value encoding/json could not encode (0.3.2.1).

Initialised with github.com/kitsunium/sdk/internal/core/data/codec/json.CodeJSONMarshalFailed.

Code 0.3.2.1

const CodeUnmarshalFailed errs.Code = 197122

CodeUnmarshalFailed identifies input that is not JSON the target can hold (0.3.2.2).

Initialised with github.com/kitsunium/sdk/internal/core/data/codec/json.CodeJSONUnmarshalFailed.

Code 0.3.2.2

const Format = "json"

Format is the name JSON is registered under. It is an untyped constant, so it goes wherever a format name is taken — config.FSSource's string, i18n.LoadFS's codec.Format — without a conversion.

Variables

var MarshalFailed *errs.Error

MarshalFailed is the sentinel of CodeMarshalFailed.

Initialised with github.com/kitsunium/sdk/internal/core/data/codec/json.MarshalFailed.

Code 0.3.2.1 · reason MARSHAL_FAILED · public "JSON encoding failed"

var UnmarshalFailed *errs.Error

UnmarshalFailed is the sentinel of CodeUnmarshalFailed.

Initialised with github.com/kitsunium/sdk/internal/core/data/codec/json.UnmarshalFailed.

Code 0.3.2.2 · reason UNMARSHAL_FAILED · public "JSON decoding failed"

Generated from docs/api by tools/genindex.

Documentation

Overview

Package json registers the JSON codec with the SDK's codec registry — and no other codec — when it is imported (ADR 0134):

import _ "github.com/kitsunium/sdk/pkg/v1/data/codec/json"

Everything that dispatches through the registry by format name then reads and writes JSON: config.FileSource and config.FSSource, i18n.LoadFS, and the codec package's Marshal and Unmarshal. Importing github.com/kitsunium/sdk/pkg/v1/data/codec instead registers every format the SDK ships — BSON, CBOR, MessagePack and the rest — which a program that only reads JSON does not need to link. This package links the JSON codec, the core package declaring its codes and the standard library's encoding/json, and nothing else.

Importing both packages is harmless: a format is registered by the package that implements it, which Go initialises once however many packages import it.

Errors

Failures carry the range 0.3.2.*; match them with errs.HasCode, or the sentinels with errors.Is:

CodeMarshalFailed    0.3.2.1  encoding/json could not encode the value
CodeUnmarshalFailed  0.3.2.2  the input is not JSON the target can hold

Index

Constants

View Source
const (
	// CodeMarshalFailed identifies a value encoding/json could not encode (0.3.2.1).
	CodeMarshalFailed errs.Code = corejson.CodeJSONMarshalFailed
	// CodeUnmarshalFailed identifies input that is not JSON the target can hold (0.3.2.2).
	CodeUnmarshalFailed errs.Code = corejson.CodeJSONUnmarshalFailed
)

The error codes, range 0.3.2.*, declared in the core (ADR 0160).

View Source
const Format = "json"

Format is the name JSON is registered under. It is an untyped constant, so it goes wherever a format name is taken — config.FSSource's string, i18n.LoadFS's codec.Format — without a conversion.

Variables

View Source
var (
	// MarshalFailed is the sentinel of [CodeMarshalFailed].
	MarshalFailed = corejson.MarshalFailed
	// UnmarshalFailed is the sentinel of [CodeUnmarshalFailed].
	UnmarshalFailed = corejson.UnmarshalFailed
)

The sentinels, for errors.Is: each carries the code of the same name.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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