Documentation
¶
Index ¶
- func DeepCopyJSON(x map[string]any) map[string]any
- func LeafPaths(m map[string]any, prefix string) []string
- func MapSliceToStructSlice[T any](in []map[string]any) ([]T, error)
- func NestedFieldCopy(obj map[string]any, fields ...string) (any, bool, error)
- func NestedMap(obj map[string]any, fields ...string) (map[string]any, bool, error)
- func NestedMapNoCopy(obj map[string]any, fields ...string) (map[string]any, bool, error)
- func NestedSlice(obj map[string]any, fields ...string) ([]any, bool, error)
- func NestedSliceNoCopy(obj map[string]any, fields ...string) ([]any, bool, error)
- func NestedString(obj map[string]any, fields ...string) (string, error)
- func NestedValue(obj map[string]any, fields []string) (any, bool)
- func ParsePath(path string) []string
- func Reorder(input map[string]any, paths []string) map[string]any
- func SetNestedField(obj map[string]any, value any, fields ...string) error
- func SetNestedValue(obj map[string]any, fields []string, newValue any) error
- func StructSliceToMapSlice[T any](results []T) ([]map[string]any, error)
- func ToMapSlice(in []any) ([]map[string]any, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeepCopyJSON ¶
DeepCopyJSON deep copies the passed value, assuming it is a valid JSON representation i.e. only contains types produced by json.Unmarshal() and also int64. bool, int64, float64, string, []any, map[string]any, json.Number and nil
func NestedFieldCopy ¶
NestedFieldCopy returns a deep copy of the value of a nested field. Returns false if the value is missing. No error is returned for a nil field.
Note: fields passed to this function are treated as keys within the passed object; no array/slice syntax is supported.
func NestedMap ¶
NestedMap returns a deep copy of map[string]any value of a nested field. Returns false if value is not found and an error if not a map[string]any.
func NestedMapNoCopy ¶
NestedMapNoCopy returns a map[string]any value of a nested field. Returns false if value is not found and an error if not a map[string]any.
func NestedSlice ¶
NestedSlice returns a deep copy of []any value of a nested field. Returns false if value is not found and an error if not a []any.
func NestedSliceNoCopy ¶
func SetNestedField ¶
SetNestedField sets the value of a nested field to a deep copy of the value provided. Returns an error if value cannot be set because one of the nesting levels is not a map[string]any.
func StructSliceToMapSlice ¶
Types ¶
This section is empty.