Skip to content

Instantly share code, notes, and snippets.

@murphysean
Created December 13, 2014 19:28
Show Gist options
  • Save murphysean/f39436eea7fc2daba4fd to your computer and use it in GitHub Desktop.
Save murphysean/f39436eea7fc2daba4fd to your computer and use it in GitHub Desktop.
go-json-schema
package main
import (
"fmt"
"github.com/xeipuuv/gojsonschema"
)
func main() {
schemaMap := map[string]interface{}{
"type": "object"}
schemaDocument, _ := gojsonschema.NewJsonSchemaDocument(schemaMap)
jsonDocument := map[string]interface{}{
"name": "john"}
result := schemaDocument.Validate(jsonDocument)
if result.Valid() {
fmt.Println("VALID!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment