jsoncodec

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: LGPL-3.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jsoncodec provides the process-wide JSON codec used to serialize and deserialize the JSON that crosses the MaaFramework native boundary. The defaults are encoding/json's Marshal and Unmarshal; the maa package exposes the codec through SetJSONEncoder, SetJSONDecoder, GetJSONEncoder, GetJSONDecoder, and ResetJSONCodec. The encoder and decoder may be replaced concurrently with use; lookups are atomic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

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

Marshal serializes v with the current process-wide encoder.

func Reset

func Reset()

Reset restores the default encoding/json Marshal and Unmarshal.

func SetDecoder

func SetDecoder(decoder Decoder)

SetDecoder atomically replaces the process-wide decoder. It panics if decoder is nil.

func SetEncoder

func SetEncoder(encoder Encoder)

SetEncoder atomically replaces the process-wide encoder. It panics if encoder is nil.

func Unmarshal

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

Unmarshal deserializes data into v with the current process-wide decoder.

Types

type Decoder

type Decoder func(data []byte, v any) error

Decoder is the function type that deserializes JSON into a value.

func GetDecoder

func GetDecoder() Decoder

GetDecoder returns the current process-wide decoder.

type Encoder

type Encoder func(v any) ([]byte, error)

Encoder is the function type that serializes a value into JSON.

func GetEncoder

func GetEncoder() Encoder

GetEncoder returns the current process-wide encoder.

Jump to

Keyboard shortcuts

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