json

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: MIT Imports: 4 Imported by: 0

README

json

Package json provides a common interface for encoding and decoding JSON data.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader, v interface{}) error

Decode decodes JSON data from the given io.Reader into the provided interface{}. It uses the sonic decoder to decode the data and returns an error if any error occurs during the decoding process.

Parameters: - r: The io.Reader to read the JSON data from. - v: The interface{} to decode the JSON data into.

Returns: - error: An error if any error occurs during the decoding process, otherwise nil.

func Encode

func Encode(w io.Writer, v interface{}) error

Encode encodes the provided value into JSON format and writes it to the provided io.Writer.

The function returns an error if there was an issue encoding the value.

func MarshalIndent

func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)

MarshalIndent encodes the provided value into JSON format with indentation. It returns the JSON encoded data and an error if any error occurs during the encoding process.

Parameters: - v: The value to be encoded into JSON format. - prefix: The prefix to be added at the beginning of each line of indented JSON data. - indent: The string used for indentation.

Returns: - []byte: The JSON encoded data. - error: An error if any error occurs during the encoding process, otherwise nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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