jsonx

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get added in v0.1.1

func Get(json, path string) (string, error)

func GetBytes added in v0.1.1

func GetBytes(json []byte, path string) ([]byte, error)

func Marshal

func Marshal(v interface{}) ([]byte, error)

Marshal marshals v into json bytes.

func MarshalToString

func MarshalToString(v interface{}) (string, error)

MarshalToString marshals v into a string.

func RegisterCodec added in v0.1.1

func RegisterCodec(codec Codec)

RegisterCodec registers the provided Codec for use with all Transport clients and servers.

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Unmarshal unmarshals data bytes into v.

func UnmarshalFromReader

func UnmarshalFromReader(reader io.Reader, v interface{}) error

UnmarshalFromReader unmarshals v from reader.

func UnmarshalFromString

func UnmarshalFromString(str string, v interface{}) error

UnmarshalFromString unmarshals v from str.

Types

type Codec added in v0.1.1

type Codec interface {
	// Marshal returns the wire format of v.
	Marshal(v interface{}) ([]byte, error)
	// MarshalToString returns the wire format of v.
	MarshalToString(v interface{}) (string, error)
	// Unmarshal parses the wire format into v.
	Unmarshal(data []byte, v interface{}) error
	// UnmarshalFromString parses the wire format into v.
	UnmarshalFromString(str string, v interface{}) error
	// UnmarshalFromReader parses the wire format into v.
	UnmarshalFromReader(reader io.Reader, v interface{}) error
	// Get parses the wire format into v.
	Get(str, path string) (string, error)
	// GetBytes parses the wire format into v.
	GetBytes(json []byte, path string) ([]byte, error)
	// Name returns the name of the Codec implementation. The returned string
	// will be used as part of content type in transmission.  The result must be
	// static; the result cannot change between calls.
	Name() string
}

Codec defines the interface Transport uses to marshal and unmarshals messages. Note that implementations of this interface must be thread safe; a Codec's methods can be called from concurrent goroutines.

func GetCodec added in v0.1.1

func GetCodec() Codec

GetCodec gets a registered Codec by content-subtype, or nil if no Codec is registered for the content-subtype.

The content-subtype is expected to be lowercase.

type RawMessage added in v0.1.1

type RawMessage = json.RawMessage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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