Help us shape the future of Go! Take the 2026 Go Developer Survey

json

package
v3.1.61 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultJSONHandler = getDefaultJSONHandler()

Functions

func Indent

func Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error

Indent appends to dst an indented form of the JSON-encoded src.

func Marshal

func Marshal(v any) ([]byte, error)

Marshal converts object as bytes

func MarshalIndent

func MarshalIndent(v any, prefix, indent string) ([]byte, error)

MarshalIndent copied from encoding/json

func MarshalKeepOptionalEmpty

func MarshalKeepOptionalEmpty(v any) ([]byte, error)

func Unmarshal

func Unmarshal(data []byte, v any) error

Unmarshal decodes object from bytes

func UnmarshalHandleDoubleEncode

func UnmarshalHandleDoubleEncode(bs []byte, v any) error

UnmarshalHandleDoubleEncode - due to a bug in xorm (see https://gitea.com/xorm/xorm/pulls/1957) - it's possible that a Blob may be double encoded or gain an unwanted prefix of 0xff 0xfe.

func Valid

func Valid(data []byte) bool

Valid proxy to json.Valid

Types

type Decoder

type Decoder interface {
	Decode(v any) error
}

Decoder represents a decoder for json

func NewDecoder

func NewDecoder(reader io.Reader) Decoder

NewDecoder creates a decoder to read objects from reader

func NewDecoderCaseInsensitive

func NewDecoderCaseInsensitive(reader io.Reader) Decoder

type Encoder

type Encoder interface {
	Encode(v any) error
}

Encoder represents an encoder for json

func NewEncoder

func NewEncoder(writer io.Writer) Encoder

NewEncoder creates an encoder to write objects to writer

type Interface

type Interface interface {
	Marshal(v any) ([]byte, error)
	Unmarshal(data []byte, v any) error
	NewEncoder(writer io.Writer) Encoder
	NewDecoder(reader io.Reader) Decoder
	Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error
}

Interface represents an interface to handle json data

type RawMessage

type RawMessage = json.RawMessage

RawMessage is a raw encoded JSON value. It implements Marshaler and Unmarshaler and can be used to delay JSON decoding.

Source Files

  • json.go
  • jsongoccy.go
  • jsonlegacy.go
  • jsonv1.go

Jump to

Keyboard shortcuts

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