serialize

package
v0.8.49 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(v any, indent int) string

As returns JSON string representation of v; when indent > 0, it pretty-prints with that many spaces.

func BytesJSON

func BytesJSON(v any) ([]byte, error)

BytesJSON returns the compact JSON bytes and any error encountered.

func BytesJSONIndent

func BytesJSONIndent(v any, indent string) ([]byte, error)

BytesJSONIndent returns the indented JSON bytes and any error encountered.

func BytesYAML added in v0.0.17

func BytesYAML(v any) ([]byte, error)

BytesYAML returns the YAML bytes and any error encountered.

func JSON

func JSON(v any) string

JSON returns a compact JSON string representation of v. On error, it returns a best-effort fallback using fmt with the error appended.

func JSONIndent

func JSONIndent(v any, indent string) string

JSONIndent pretty-prints v as JSON with the provided indent string (e.g., " " or "\t"). On error, it returns a best-effort fallback using fmt with the error appended.

func JSONIndentN

func JSONIndentN(v any, n int) string

JSONIndentN pretty-prints v as JSON with n spaces of indentation (n <= 0 defaults to 2).

func Pretty

func Pretty(v any) string

Pretty is a convenience alias for JSONIndentN(v, 2).

func PrettyYAML added in v0.0.17

func PrettyYAML(v any) string

PrettyYAML is an alias for YAML (YAML is pretty by default).

func YAML added in v0.0.17

func YAML(v any) string

YAML returns a YAML string representation of v. YAML is naturally indented/pretty-printed by default. On error, it returns a best-effort fallback using fmt with the error appended.

Types

This section is empty.

Jump to

Keyboard shortcuts

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