jsonschema icon indicating copy to clipboard operation
jsonschema copied to clipboard

consider API methods supporting io.Reader

Open maxthomas opened this issue 6 years ago • 1 comments

passing around io.Readers is broadly supported in the golang ecosystem, but this API only supports []byte as input.

have you considered adding support for taking in io.Readers in the API?

maxthomas avatar Aug 16 '19 15:08 maxthomas

Supporting an interface which is a subset of json.Decoder as input would be more useful. json.NewDecoder can take an io.Reader as input.

See how package github.com/dolmen-go/jsonptr uses jsonptr.JSONDecoder as input for extracting data from JSON documents with jsonptr.Get:

type JSONDecoder interface {
	Token() (json.Token, error)
	More() bool
	Decode(interface{}) error
}

Disclaimer: I'm the author of this jsonptr package.

dolmen avatar Apr 28 '20 10:04 dolmen