Documentation
¶
Index ¶
- func SplitKey(key string, delim ...string) []string
- type KeyVal
- func (kv *KeyVal) Array(keys ...string) ([]any, error)
- func (kv *KeyVal) Boolean(keys ...string) (bool, error)
- func (kv *KeyVal) Copy() *KeyVal
- func (kv *KeyVal) CreateValue(value any, keys ...string) error
- func (kv *KeyVal) GetKeyVal(keys ...string) (*KeyVal, error)
- func (kv *KeyVal) Mapping(keys ...string) (map[string]any, error)
- func (kv *KeyVal) Number(keys ...string) (float64, error)
- func (kv *KeyVal) SetValue(value any, keys ...string) error
- func (kv *KeyVal) Stack(layer *KeyVal) *KeyVal
- func (kv *KeyVal) String(keys ...string) (string, error)
- func (kv *KeyVal) ToJson() ([]byte, error)
- func (kv *KeyVal) ToYaml() ([]byte, error)
- func (kv *KeyVal) Value(keys ...string) (any, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type KeyVal ¶
type KeyVal struct {
// contains filtered or unexported fields
}
func NewFromJson ¶
NewFromJson returns a new KeyVal instance from a JSON source
func NewFromMap ¶
NewFromMap returns a new KeyVal instance from a map[string]any
func NewFromYaml ¶
NewFromJson returns a new KeyVal instance from a YAML source
func (*KeyVal) Array ¶
Array returns an array or an error if the data can't be found, or properly cast
func (*KeyVal) Boolean ¶
Boolean returns a boolean or an error if the data can't be found, or properly cast
func (*KeyVal) CreateValue ¶ added in v0.1.4
CreateValue sets a nested value within the object. If a parent key cannot be located, it is created. Key collisions are ignored.
func (*KeyVal) GetKeyVal ¶ added in v0.1.7
GetKeyVal returns a new KeyVal object at the nested key position.
func (*KeyVal) Mapping ¶
Mapping returns an array or an error if the data can't be found, or properly cast
func (*KeyVal) Number ¶
Number returns a float or an error if the data can't be found, or properly cast
func (*KeyVal) SetValue ¶
SetValue sets a nested value within the object. If a parent key cannot be located, an error is returned.
func (*KeyVal) Stack ¶
Stack creates a new KeyVal object with the current instance being the base, and layer being stacked atop
func (*KeyVal) String ¶
String returns a string or an error if the data can't be found, or properly cast
func (*KeyVal) ToJson ¶ added in v0.1.6
ToJson marshals the entire data structure to a JSON byte array