Documentation
¶
Index ¶
- func DottedPathToJSONPointerPath(path string) (string, error)
- func GetMapPathValue(data map[string]any, path string) (any, error)
- func GetPathValue[T any](data T, path string) (any, error)
- func GetSlicePathValue(data []any, path string) (any, error)
- func JSONPointerPathToDottedPath(path string) (string, error)
- func ParseAnyToDottedPath(data any, inc func(key, value any) bool) []string
- func ParseDottedPath(path string) ([]string, error)
- func ParseJSONPointer(path string) ([]string, error)
- func PartsToDottedPath(parts []string) string
- func PartsToJSONPointerPath(parts []string) (string, error)
- func SetPathValue[T any](data T, path string, value any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DottedPathToJSONPointerPath ¶
DottedPathToJSONPointerPath converts a dotted path to a JSON Pointer path.
It returns an error if the path is invalid.
func GetMapPathValue ¶
GetMapPathValue returns the value at the given path in the map.
It performs faster than the generic GetPathValue function. It returns an error if the path is invalid or the value is not found.
func GetPathValue ¶
GetPathValue returns the value at the given path in the data.
It returns an error if the path is invalid or the value is not found.
func GetSlicePathValue ¶
GetSlicePathValue returns the value at the given path in the slice.
It performs faster than the generic GetPathValue function. It returns an error if the path is invalid or the value is not found.
func JSONPointerPathToDottedPath ¶
JSONPointerPathToDottedPath converts a JSON Pointer path to a dotted path.
It returns an error if the path is invalid.
func ParseAnyToDottedPath ¶ added in v0.15.0
ParseAnyToDottedPath parses any to dotted path. includes any key-value/index-element pairs from the data for which the inc function returns true. if inc is nil, default to always include.
It returns a list of paths found in the given data, sorted by "path length" and lexical order.
func ParseDottedPath ¶
ParseDottedPath parses a dotted path into its segments.
It returns an error if the path is invalid.
func ParseJSONPointer ¶
ParseJSONPointer parses a JSON Pointer path into its segments. The JSON Pointer path is a string that represents a path to a value in a JSON document. The JSON Pointer path follows the specification defined in RFC 6901.
It returns an error if the path is invalid.
func PartsToDottedPath ¶
PartsToDottedPath converts path parts to a dotted path.
It returns an error if the parts constitute an invalid path.
func PartsToJSONPointerPath ¶
PartsToJSONPointerPath converts path parts to a JSON Pointer path.
It returns an error if the parts constitute an invalid path.
func SetPathValue ¶
SetPathValue sets the given value at the given path in the data.
Currently only supports []any and map[string]any data types. If data is nil, the value cannot be set, but no error is returned. It returns an error if the path is invalid or the value cannot be set.
Types ¶
This section is empty.