Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MapEntryResolver ¶
MapEntryResolver resolves a value from a map.
func (*MapEntryResolver) Expression ¶
func (r *MapEntryResolver) Expression() ast.Expr
Expression returns the corresponding ast.Expr.
func (*MapEntryResolver) Resolve ¶
func (r *MapEntryResolver) Resolve(v interface{}) (interface{}, error)
Resolve resolves the value of an entry on the map.
type ResolveError ¶
type ResolveError struct { Msg string Code string // Pos is the position in the corresponding key-path of the underlying // expression that the resolver was dervied from. Pos int }
ResolveError represents an error that occured while resolving a value for a given selector.
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector represents a value selection on an object.
func Parse ¶
Parse parses a traversal tree from the selector string and returns a new Selector instance.
func (*Selector) Resolve ¶
Resolve resolves the value at the specified key-path, if any, from the provided object. The root object must be an indexable type such as a Map `map[string]interface{}` or a Slice `[]interface{}`.
All errors will be prefixed with the sub-key-path the error occured at.
Example usage:
sel := Parse("test[0].foo") sel.Resolve(map[string]interface{}{ "test": []map[string]interface{}{ {"foo": "bar"} } })
type SliceElementResolver ¶
SliceElementResolve resolves values from a slice.
func (*SliceElementResolver) Expression ¶
func (r *SliceElementResolver) Expression() ast.Expr
Expression returns the corresponding ast.Expr.
func (*SliceElementResolver) Resolve ¶
func (r *SliceElementResolver) Resolve(v interface{}) (interface{}, error)
Resolve resolves the value of the element at the index on the slice.
type TraversalTreeNode ¶
type TraversalTreeNode struct { Resolver Resolver Parent *TraversalTreeNode Child *TraversalTreeNode }
TraversalTreeNode represents a tree node responsible for traversing a given object.