Documentation
¶
Overview ¶
Package fieldpath reads nested values out of a decoded JSON object (map[string]any) by path. The default syntax is a dot-separated path, like "user.id". A path that begins with "/" is instead an RFC 6901 JSON Pointer ("/user/id"), which can address a key that itself contains a dot ("/http.status"). It is the lookup the field-matching rules build on.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
Get is Lookup for a path that has not been split yet. An empty path returns (nil, false).
func Lookup ¶
Lookup walks fields by precompiled segments and returns the value at the end and whether it was found. A segment that is missing, or that tries to descend into something that is not an object, returns (nil, false), as does an empty path. A path may end on any value, including a nested object or an array; descending into an array (numeric indexing) is not supported.
func Split ¶
Split breaks a path into segments. A "/"-prefixed path is parsed as a JSON Pointer (see splitPointer); otherwise it is split on ".". An empty path returns nil so it round-trips through Lookup the same way Get treats "". Callers on a hot path should Split once and reuse the result with Lookup rather than calling Get per record.
Types ¶
This section is empty.