jsonx

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

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

Marshal encode value to json data, without html escape

func MarshalString added in v2.3.0

func MarshalString(v interface{}, options ...MarshalOption) (string, error)

MarshalString encode value to json string, without html escape

func UnMarshal

func UnMarshal[T any](data []byte) (T, error)

UnMarshal parse json encoded data to value, return the value. param T: the T can be pointer type, or plain value type.

func UnMarshalString added in v2.3.0

func UnMarshalString[T any](jsonStr string) (T, error)

UnMarshal parse json encoded string to value, return the value. param T: the T can be pointer type, or plain value type.

Types

type MarshalOption added in v2.3.0

type MarshalOption func(*json.Encoder)

MarshalOption set marshal behavers for json marshal

func EscapeHTML added in v2.3.0

func EscapeHTML() MarshalOption

EscapeHTML escape html chars

func WithIndent added in v2.3.0

func WithIndent(indent string) MarshalOption

WithIndent set indent for json marshal

Jump to

Keyboard shortcuts

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