Documentation
¶
Index ¶
- func Encode(w io.Writer, v any) (err error)
- func Marshal(v any) (data []byte, err error)
- func NumberEqual(numberExp, numberGot Number) (eq bool)
- func Unmarshal(input []byte, output any) (err error)
- func UnmarshalPlain(input []byte, output any) (err error)
- func UnmarshalString(input string, output any) (err error)
- type Array
- type Bool
- type Number
- type Object
- type RawMessage
- type String
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NumberEqual ¶
NumberEqual is comparing the string representation of the json.Number. It fails to compare different formats, 1e10 != 10000000000, although it is the same mathematical value.
func UnmarshalPlain ¶ added in v1.61.0
UnmarshalPlain decodes the input bytes into the output like Unmarshal, but without the cjson comment / trailing comma handling. Use it for JSON which was produced by marshaling or received from a server, that JSON cannot contain comments and running the comment passes over it is wasted work.
It runs on the json/v2 engine: unlike the v1 json.Decoder, which copies the input into its internal buffer and decodes generic values through reflect, jsontext parses the []byte in place (bytes.Buffer fast path) and the `any` tree is built by a plain token loop. Semantics are kept at v1: see unmarshalPlainOpts, and like the old Decoder.Decode, only the first JSON value is read, trailing data is ignored. On error the old v1 decode is re-run on the same input so error values and texts stay byte-identical.
func UnmarshalString ¶
UnmarshalString is a wrapper for Unmarshal for string input
Types ¶
type RawMessage ¶
type RawMessage = json.RawMessage