Struct for marshaling and unmarshaling glTF
go get github.com/sturfeeinc/glTF/model
It's autogenerated code from official work group's specs. Don't edit it. Edit the generator
-
easyjson for the fastest serialization.
-
validator.v9 for validation (via tags)
There are not auto validation. You can use validator.v9 explicitly before json.Marshal.
package main import ( "encoding/json" "github.com/sturfeeinc/glTF/model" "gopkg.in/go-playground/validator.v9" ) func main() { validate := validator.New() gltf := glTF{} // ... err := validate.Struct(gltf) if err != nil { // handling } res, err := json.Marshal(gltf) println(res) }I thought about realization of strict validation in MarshalJSON and UnmarshalJSON for every struct. But for now it will to much complex.
- Petr Lozhkin im7mortal@gmail.com