Documentation
¶
Overview ¶
Package docutil has the small operations on JSON-shaped documents (nested map[string]any and []any) that several packages need: copying, merge patches and dot paths. It imports only the standard library, so any package may use it.
Index ¶
- func CopyPath(dst, src map[string]any, path []string)
- func DeepCopy(v any) any
- func DeepCopyMap(m map[string]any) map[string]any
- func Get(doc map[string]any, path string) any
- func GetPath(doc map[string]any, path string) (v any, ok bool)
- func MergePatch(target, patch map[string]any) map[string]any
- func RemovePath(doc map[string]any, path string)
- func SetPath(doc map[string]any, path string, v any)
- func SetPathExisting(doc map[string]any, path string, v any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyPath ¶
CopyPath copies the value at path (the parts of a dot path) from src into dst, keeping the nesting. A missing path adds nothing, and no empty object is left behind.
func DeepCopy ¶
DeepCopy copies the maps and slices of a JSON-shaped value; other values are shared.
func DeepCopyMap ¶
DeepCopyMap is DeepCopy for a document.
func GetPath ¶
GetPath reads a dot path ("a.b.c") of a document; ok is false when a member on the way is missing or is not an object.
func MergePatch ¶
MergePatch applies an RFC 7396 JSON Merge Patch object to target, which is modified in place and returned. A null value removes the member.
func RemovePath ¶
RemovePath deletes the value at a dot path of a document, if it is there.
Types ¶
This section is empty.