Documentation
¶
Overview ¶
Package jsonpath parses the path syntax the autoupdate configuration uses to point at a value inside a JSON document, such as "tag_name", "[0].sha" or "versions[0].version".
A path is a non-empty sequence of segments. A field segment is one or more characters other than '.', '[' and ']', and every field except a leading one is preceded by exactly one '.'. An index segment is "[N]", N being one or more ASCII digits; it follows a field, another index or the start of the path, with no '.' before it. Any other path is rejected with an error that wraps ErrInvalidJSONPath and quotes the path.
The package imports only the standard library, so the response parser and the registry validator can share one grammar and reach the same verdict.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidJSONPath = errors.New("invalid JSON path syntax")
ErrInvalidJSONPath is wrapped by every error Parse returns.
Functions ¶
func CutWildcard ¶
CutWildcard splits a versions path at a leading "[*]", the wildcard that applies the rest of the path to every item of an array. It reports whether the wildcard is present and returns the path each item is read with: "" for the item itself, or a path Parse accepts. After "[*]" the rest is either nothing, an index ("[*][0]"), or a '.' followed by a non-empty path. A path without the wildcard is checked by Parse and returned unchanged.