JSON

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: BSL-1.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrettyEncode

func PrettyEncode(data interface{}, out io.Writer) error

If you use json.Encode, you can set indentation through Encoder. SetIndent method similarly to as in marshaling, by defining a prefix and indent.

func PrettyString

func PrettyString(str string) (string, error)

Package encoding/json also has a useful function json.Indent to beautify JSON string without indentation to JSON with indentation. The function needs the source JSON, output buffer, prefix, and indent.

func PrettyStruct

func PrettyStruct(data interface{}) (string, error)

Function json.MarshalIndent generates JSON encoding of the value with indentation. You can specify a prefix of each JSON line and indent copied one or more times according to the indentation level. In our example, we pretty-print JSON using four spaces for indentation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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