Documentation
¶
Index ¶
- Constants
- func Base64JSONDecode[T any](s string) (T, error)
- func Base64JSONEncode[T any](t T) string
- func Canonicalize(raw []byte) ([]byte, error)
- func CanonicalizeObject(raw []byte, maximum int) ([]byte, error)
- func CloneJSON[T any](input T) (T, error)
- func CloneJSONInValue[T any](in T) T
- func DecodeCanonicalObject[T any](raw []byte, maximumBytes int) (T, error)
- func DecodeJSONRaw[T any](raw json.RawMessage) (T, error)
- func EncodeToJSONRaw(value any) (json.RawMessage, error)
- func Equal(left, right []byte) bool
- func LogJSON(level slog.Level, v any)
- func MarshalCanonicalObject(value any, maximumBytes int) (json.RawMessage, error)
- type JSONRawString
- type JSONSchema
Constants ¶
const (
EmptyObject = "{}"
)
Variables ¶
This section is empty.
Functions ¶
func Base64JSONDecode ¶
func Base64JSONEncode ¶
func Canonicalize ¶ added in v0.2.13
func CanonicalizeObject ¶ added in v0.2.13
func CloneJSON ¶ added in v0.2.17
CloneJSON returns a copy of input produced by a JSON marshal/unmarshal round trip. It intentionally does not use DecodeJSONRaw, because clone semantics should match json.Unmarshal rather than reject unknown fields.
func CloneJSONInValue ¶ added in v0.2.17
func CloneJSONInValue[T any](in T) T
func DecodeCanonicalObject ¶ added in v0.2.17
DecodeCanonicalObject validates raw as one JSON object, canonicalizes it, and strictly decodes it into T. It rejects duplicate keys, unknown struct fields, and trailing JSON values.
As with CanonicalizeObject, an empty raw value is treated as {}.
func DecodeJSONRaw ¶
func DecodeJSONRaw[T any](raw json.RawMessage) (T, error)
DecodeJSONRaw decodes a json.RawMessage into a typed value T, disallowing unknown fields and rejecting trailing data. If raw is empty, or only whitespace, it returns the zero value of T.
func EncodeToJSONRaw ¶
func EncodeToJSONRaw(value any) (json.RawMessage, error)
EncodeToJSONRaw encodes any value to json.RawMessage. No typed method here as value being of a type doesnt really affect its functionality.
func MarshalCanonicalObject ¶ added in v0.2.17
func MarshalCanonicalObject(value any, maximumBytes int) (json.RawMessage, error)
MarshalCanonicalObject marshals value as a canonical JSON object. The maximum applies to the marshaled JSON before canonicalization.
Types ¶
type JSONRawString ¶ added in v0.2.17
type JSONRawString string
func (JSONRawString) MarshalJSON ¶ added in v0.2.20
func (value JSONRawString) MarshalJSON() ([]byte, error)
func (*JSONRawString) UnmarshalJSON ¶ added in v0.2.20
func (value *JSONRawString) UnmarshalJSON(raw []byte) error
type JSONSchema ¶ added in v0.2.17
type JSONSchema = json.RawMessage