jsonenc

package
v0.0.0-...-5a6e01e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package jsonenc support encoding and decoding instance by json.

Index

Constants

View Source
const (
	NULL = "null"
)

Variables

View Source
var (
	JSONEncoderType = hint.Type("json-encoder")
	JSONEncoderHint = hint.NewHint(JSONEncoderType, "v0.0.1")
)

Functions

func Marshal

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

func MarshalIndent

func MarshalIndent(i interface{}) ([]byte, error)

func MustMarshal

func MustMarshal(i interface{}) []byte

func MustMarshalIndent

func MustMarshalIndent(i interface{}) []byte

func ToString

func ToString(i interface{}) string

func Unmarshal

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

Types

type Encoder

type Encoder struct {
	*hint.Hintset
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder() *Encoder

func (*Encoder) Add

func (enc *Encoder) Add(ht hint.Hinter) error

func (*Encoder) Decode

func (enc *Encoder) Decode(b []byte) (hint.Hinter, error)

func (*Encoder) DecodeMap

func (enc *Encoder) DecodeMap(b []byte) (map[string]hint.Hinter, error)

func (*Encoder) DecodeSlice

func (enc *Encoder) DecodeSlice(b []byte) ([]hint.Hinter, error)

func (*Encoder) DecodeWithHint

func (enc *Encoder) DecodeWithHint(b []byte, ht hint.Hint) (hint.Hinter, error)

func (*Encoder) Hint

func (*Encoder) Hint() hint.Hint

func (*Encoder) Marshal

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

func (*Encoder) Unmarshal

func (*Encoder) Unmarshal(b []byte, v interface{}) error

type HintedHead

type HintedHead struct {
	H hint.Hint `json:"_hint"`
}

func NewHintedHead

func NewHintedHead(h hint.Hint) HintedHead

type Unpackable

type Unpackable interface {
	UnpackJSON([]byte, *Encoder) error
}

Jump to

Keyboard shortcuts

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