jsonpointer
jsonpointer copied to clipboard
JSONParent interface doesn't match it's documentation, nor is useful with jsonschema.Schema
Issue
I'm trying to traverse a *jsonschema.Schema using this library and notice that this library declares the following interface:
// JSONParent is an interface that enables tree traversal by listing
// all immediate children of an object
type JSONParent interface {
// JSONChildren should return all immidiate children of this element
// with json property names as keys, go types as values
// Note that implementations on slice-types are expected to convert
// integers to string keys
JSONProps() map[string]interface{}
}
Note that the JSONProps() function is actually documented as JSONChildren.
Also, https://github.com/qri-io/jsonschema exposes the JSONChildren() function and not JSONProps().
Do you have a suggested fix?
Two options:
- Don't introduce breaking changes and update the documentation here. Then update the
jsonschemapackage to implement bothJSONProps()andJSONChildren()(which implements the same behaviour) - Make a breaking change to this repo and change the signature to match the documentation. The only change to
jsonschemawould be to updatego.modwith the latest version.
Looking more into this, I notice that jsonschema actually implements JSONChildren() map[string]JSONPather. Notice the value-type of the map is JSONPather and not interface{}.
I think this should be closed and add a new method to the relevant keywords within jsonschema for JSONProps() map[string]interface{}