Expand description
Go encoding/json for the plugin RPC contract.
Most sdk/pluginapi structs carry no json tags, so the wire names are the Go field
names (AuthID, StorageJSON). Encoding follows json.Marshal: fields in
declaration order, omitempty, HTML-escaped strings, []byte as padded standard
base64, maps with sorted keys, time.Time as RFC 3339 with nanoseconds. Decoding
follows json.Unmarshal: a key matches its field exactly or, failing that,
case-insensitively; unknown keys are ignored; the last duplicate wins; null leaves
scalars alone and clears slices and maps; numbers into integer fields must be integer
literals.
Decoding walks a Node tree that keeps every object member and number literal,
and follows Go’s decode-into-existing rules: struct fields and map keys merge into
what is already there (a map element itself is decoded fresh), a pointer decodes
into its pointee, a slice reuses its elements.
Structs are declared with go_struct!. []byte is
bytes::Bytes; map[string]any and any are serde_json::Value.
ponytail: an empty slice, map or []byte encodes as null (Go’s nil). Fields Go
builds non-nil while empty use NonNil.
Structs§
- Decode
Error - GoTime
time.Time;Noneis the zero time (0001-01-01T00:00:00Z).- NonNil
- A slice or map Go builds non-nil even when empty: encodes
[]/{}. - NonNil
Bytes - A
[]byteGo builds non-nil (for example fromio.ReadAll): encodes""when empty instead ofnull. - ObjWriter
- Writes one JSON object field by field.
- RawJson
json.RawMessage: marshalled compact with HTML escaping;nullwhen empty.
Enums§
Traits§
- GoJson
- A value with Go
encoding/jsonsemantics. - GoStruct
- A Go struct: encodes its fields in order and decodes them by name.
Functions§
- decode_
field_ value - Decodes one field into its current value.
- decode_
struct - Decodes an object into a fresh struct.
- decode_
struct_ into - Decodes an object member by member into an existing struct; later duplicates decode over earlier ones.
- encode_
any - Go’s encoding of a value decoded into
any. - from_
slice json.Unmarshalof a complete document.- from_
slice_ first json.NewDecoder(bytes.NewReader(raw)).Decode: the first value; seeparse_first.- in_
field - Adds the struct field to a decode error, like Go’s
UnmarshalTypeError: the innermost struct’s name and the field path from the outermost struct (array indexes and map keys are not part of it). - number_
error - A number that does not fit the numeric
go_type(Go"number " + literal). - parse
json.Unmarshal’s syntax pass and value tree.- parse_
first json.NewDecoder(r).Decodeover a complete reader: the first value only, with anything after it left unread; a truncated value isunexpected EOFand input without any valueEOF.- to_vec
json.Marshal.- type_
error - A value of the wrong JSON kind for
go_type. Go names a number without its literal here;number_erroris the numeric-range case that includes it.