Documentation ¶
Overview ¶
Package jsonutils provides functions for retrieving and converting values from unmarshalled JSON data structures.
Index ¶
- func BytesAtKey(jm map[string]any, k string) ([]byte, error)
- func IntAtKey(jm map[string]any, k string) (int, error)
- func MapAtKey(jm map[string]any, k string) (map[string]any, error)
- func SliceAtKey(jm map[string]any, k string) ([]any, error)
- func StringAtIndex(js []any, idx int) (string, error)
- func StringAtKey(jm map[string]any, k string) (string, error)
- func StringsAtKey(jm map[string]any, k string) ([]string, error)
- func UnmarshalAtKey(jm map[string]any, k string, v any) error
- type IndexOutOfBoundsError
- type IndexTypeError
- type KeyError
- type KeyTypeError
- type MissingKeyError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesAtKey ¶
BytesAtKey returns the requested key value as a slice of bytes.
func SliceAtKey ¶
SliceAtKey returns the requested key value as a JSON slice ([]any).
func StringAtIndex ¶
StringAtIndex returns the slice value at the specified index as a string.
func StringAtKey ¶
StringAtKey returns the requested key value as a string.
func StringsAtKey ¶
StringsAtKey returns the requested key value as a slice of string values.
Types ¶
type IndexOutOfBoundsError ¶
type IndexOutOfBoundsError struct { ActualLen int // contains filtered or unexported fields }
An IndexOutOfBoundsError is returned when the requested index is not valid.
func NewIndexOutOfBoundsError ¶
func NewIndexOutOfBoundsError(idx, actualLen int) *IndexOutOfBoundsError
func (*IndexOutOfBoundsError) Error ¶
func (e *IndexOutOfBoundsError) Error() string
type IndexTypeError ¶
type IndexTypeError struct {
// contains filtered or unexported fields
}
An IndexTypeError is the error that is returned when a value is requested for an index value in a slice and the value is not of the expected tpe.
func NewIndexTypeError ¶
func NewIndexTypeError(index int, expectedType string, actual any) *IndexTypeError
func (*IndexTypeError) Error ¶
func (e *IndexTypeError) Error() string
type KeyError ¶
type KeyError struct { Err error // contains filtered or unexported fields }
A KeyError wraps an error that occurs when requesting a key value.
func NewKeyError ¶
type KeyTypeError ¶
type KeyTypeError struct {
// contains filtered or unexported fields
}
A KeyTypeError is the error that is returned by functions in this package when key is requested, it exists, but is not of the expected type.
func NewKeyTypeError ¶
func NewKeyTypeError(key, expectedType string, actual any) *KeyTypeError
func (*KeyTypeError) Error ¶
func (e *KeyTypeError) Error() string
type MissingKeyError ¶
type MissingKeyError struct {
// contains filtered or unexported fields
}
A MissingKeyError is the error that is returned by functions in this package when a key is requrested and is not found.
func NewMissingKeyError ¶
func NewMissingKeyError(key string) *MissingKeyError
func (*MissingKeyError) Error ¶
func (e *MissingKeyError) Error() string