Get() inside structs
Implement Get() traversing into struct{} as requested by @lestrrat:
- if the type implements
json.Marshaler, callMarshalJSON, convert result tojson.RawMessageand then browse into that (requires #2) - else follow
encoding/jsonmapping rules using struct tags to map the struct as if it was amap[string]interface{}(an easy (but inefficient) solution could calljson.Marshal()and then follow #2)
Finally got around to considering using a new package for my json pointer needs.
Now, what I'd like to do is to apply JSON pointer semantics to a struct, namely a JSON Schema object.
I want the JSON Schema object to NOT have to be a map[string]interface{}, and I don't want to the object to have to be directly JSON-marshal-able (i.e. it has a MarshalJSON() method, but the struct definition itself is not a one-to-one mapping to the resulting JSON structure)
I think this issue means "marshal the object to JSON, then apply the logic implemented by jsonptr". Just as a thought, to avoid having to convert the struct into JSON just for this operation, would it make sense to define a type JSONGetter interface { Get(path) (interface{}, error) } or some such, to further delegate the resolution of the JSON pointer to the object itself?