schema := `{ "type": "object", "required": ["name"], "properties": { "name": {"type": "string"}, "age": {"type": "integer"} } }` // Load the schema s, err := schema.Load(schema)
doc := `{"name": "John", "age": 30}` err := s.Validate(doc) // err == nil, document is validThis validates a JSON document against the previously defined schema. The document contains the required "name" property and the optional "age" property. In conclusion, the go github.com.cloudwan.gohan.schema Schema is a package library that allows you to define and validate JSON schemas in your Go applications. The examples demonstrate how easy it is to define a schema and validate a JSON document against it.