Documentation ¶
Index ¶
- func Marshal(v interface{}) (b []byte, err error)
- func MarshalToString(v interface{}) (s string, err error)
- func Unmarshal(b []byte) (any, error)
- func UnmarshalObject(b []byte) (map[string]any, error)
- func UnmarshalObjectString(s string) (map[string]any, error)
- func UnmarshalString(s string) (any, error)
- func WalkDeNaN(obj interface{}) interface{}
- type Emitter
- type Parser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalToString ¶
func Unmarshal ¶
Unmarshal decodes a JSON representation from b as a generic value: int64, float64, string, bool, nil, []any, or map[string]any.
func UnmarshalString ¶
UnmarshalString decodes a JSON representation from b as a generic value: int64, float64, string, bool, nil, []any, or map[string]any.
Types ¶
type Emitter ¶
func NewEmitter ¶
type Parser ¶
type Parser interface { // Parse JSON from the front of the contained data as a simply-typed value // and return it. If the data is empty, the exact error io.EOF will be // returned. Parse() (any, error) // ParseObject parses JSON from the front of the contained data as a // simply-typed JSON object and return it. If the JSON is a value of a type // other than object, an error will be returned. If the data is empty, the // exact error io.EOF will be returned. ParseObject() (map[string]any, error) // NextLine consumes whitespace up to the next newline, returning an error // if something other than whitespace exists before the next newline, or // returning the exact error io.EOF if the end of data is found first. This // method reads until exactly the next '\n' newline character, not any other // combination of '\r' and '\n'; it will work with "\r\n" and "\n" newlines // only. NextLine() error // IterLines returns a Range-func iterable for reading JSONL. // // Returns an iterable go1.22+ RangeFunc that yields each line of a JSONL // until the end of data. If an error occurs, it will be yielded on its own // and iteration will stop. // // See: https://go.dev/wiki/RangefuncExperiment IterLines() func(func(any, error) bool) // IterObjectLines returns a Range-func iterable for reading JSONL, // enforcing that each line must also be a JSON object rather than another // kind of JSON value. // // Returns an iterable go1.22+ RangeFunc that yields each line of a JSONL // until the end of data. If an error occurs, it will be yielded on its own // and iteration will stop. // // See: https://go.dev/wiki/RangefuncExperiment IterObjectLines() func(func(map[string]any, error) bool) // CheckEmpty checks that the remaining data is all whitespace, returning an // error if not. CheckEmpty() error // UnmarshalFull parses JSON from the front of the contained data, then // checks if there is any data left after. If there is, the value will still // be returned but there will be a "not empty" error. If the data is empty, // the exact error io.EOF will be returned. UnmarshalFull() (any, error) // Reset the parser with a new io.Reader. Reset(io.Reader) // ResetSlice resets the parser with a new byte slice. ResetSlice([]byte) // ResetString resets the parser with a new string. ResetString(string) }
func NewParserFromSlice ¶
NewParserFromSlice creates a new parser for the given slice.
func NewParserFromString ¶
NewParserFromString creates a new parser for the given string.
Click to show internal directories.
Click to hide internal directories.