jsonutil

package
v0.85.0-pre.5 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

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

Parses JSON data into a value of type T.

func ParseFromFile

func ParseFromFile[T any](path string) (T, error)

Reads a JSON file and parses its contents into a value of type T.

func Serialize

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

Serializes a value to JSON using json.Marshal.

func SerializePretty

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

Serializes with json.MarshalIndent using tabs.

func SerializePrettyToFile

func SerializePrettyToFile(path string, v any, fm ...os.FileMode) error

Serializes a value to JSON and writes it to a file with pretty formatting. Defaults to 0644 permissions if not specified.

func SerializeToFile

func SerializeToFile(path string, v any, fm ...os.FileMode) error

Serializes a value to JSON and writes it to a file. Defaults to 0644 permissions if not specified.

Types

type JSONString

type JSONString string

JSONString is a semantic marker type for JSON payload strings.

Jump to

Keyboard shortcuts

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