santhosh-tekuri / jsonschema

JSONSchema (draft 2020-12, draft 2019-09, draft-7, draft-6, draft-4) Validation using Go
Apache License 2.0
957 stars 98 forks source link

Can add `Loader` , give schema and `[]byte` , parse to `map` or `struct` ? #107

Closed 23233 closed 1 year ago

23233 commented 1 year ago

I previously used github.com/xeipuuv/gojsonschema to validate JSON schema and extract data from JSON requests, but it has not been maintained for a long time. I'm considering switching to another library, but I noticed that it doesn't have the Loader functionality. Is there any plan or possibility to add it in the future?

Need

// w http.ResponseWriter, r *http.Request
result,err := jsonschema.SchemaDataLoader(r.Body)
if err == nil {
    data := result.(map[string]interface{}) // or some struct
}

Thank you~

santhosh-tekuri commented 1 year ago

see following examples from godoc (https://pkg.go.dev/github.com/santhosh-tekuri/jsonschema/v5)