jsonutil

package
v0.0.0-...-028f1de Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Indent

func Indent(jsonStr string) string

Indent indents a json string.

func Marshal

func Marshal(obj interface{}) (result string, err error)

Marshal marshals an object to a json string. Returns empty string if marshal fails.

func MarshalIndent

func MarshalIndent(obj interface{}) (result string, err error)

MarshalIndent is like Marshal but applies Indent to format the output. Returns empty string if marshal fails

func Remarshal

func Remarshal(obj interface{}, remarshalledObj interface{}) (err error)

Remarshal marshals an object to Json then parses it back to another object. This is useful for example when we want to go from map[string]interface{} to a more specific struct type or if we want a deep copy of the object.

func Unmarshal

func Unmarshal(jsonContent string, dest interface{}) (err error)

Unmarshal unmarshals the content in string format to an object.

func UnmarshalFile

func UnmarshalFile(filePath string, dest interface{}) (err error)

UnmarshalFile reads the content of a file then Unmarshals the content to an object.

Types

This section is empty.

Jump to

Keyboard shortcuts

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