Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultMaxRecursions = 10
var ErrMaxRecursion = errors.New("reached max number of recursions")
var ErrReferenceLoop = errors.New("reference loop detected")
Functions ¶
This section is empty.
Types ¶
type Option ¶
func WithRecursiveResolution ¶
WithRecursiveResolution allows ou to enable recursive resolution on the *result* data structure. This means that after resolving the JSON reference in the structure at hand, it does another pass at resolving the entire data structure. Depending on your structure and size, this may incur significant cost.
Please note that recursive resolution of the result is still experimental. If you find problems, please submit a pull request with a failing test case.
type Resolver ¶
type Resolver struct { MaxRecursions int // contains filtered or unexported fields }
Resolver is responsible for interpreting the provided JSON reference.
func (*Resolver) AddProvider ¶
AddProvider adds a new Provider to be searched for in case a JSON pointer with more than just the URI fragment is given.
func (*Resolver) Resolve ¶
func (r *Resolver) Resolve(v interface{}, ptr string, options ...Option) (ret interface{}, err error)
Resolve takes a target `v`, and a JSON pointer `spec`. spec is expected to be in the form of
[scheme://[userinfo@]host/path[?query]]#fragment [scheme:opaque[?query]]#fragment
where everything except for `#fragment` is optional. If the fragment is empty, an error is returned.
If `spec` is the empty string, `v` is returned This method handles recursive JSON references.
If `WithRecursiveResolution` option is given and its value is true, an attempt to resolve all references within the resulting object is made by traversing the structure recursively. Default is false