json

package
v0.0.0-...-e1367df Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

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

json序列化为[]byte

func MarshalToString

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

json序列化为string

func NewDecoder

func NewDecoder(reader io.Reader) *jsoniter.Decoder

读取数据流

func NewEncoder

func NewEncoder(writer io.Writer) *jsoniter.Encoder

写入数据流

func Unmarshal

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

[]byte反序列化json

func UnmarshalFromString

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

string反序列化json

func WriteJSON

func WriteJSON(w http.ResponseWriter, obj interface{}) error

WriteJSON marshals the given interface object and writes it with custom ContentType.

Types

type JsoniterJSON

type JsoniterJSON struct {
	Data interface{}
}

JSON contains the given interface object.

func (JsoniterJSON) Render

func (r JsoniterJSON) Render(w http.ResponseWriter) (err error)

Render (JSON) writes data with custom ContentType.

func (JsoniterJSON) WriteContentType

func (r JsoniterJSON) WriteContentType(w http.ResponseWriter)

WriteContentType (JSON) writes JSON ContentType.

Jump to

Keyboard shortcuts

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