removed custom tests - moving to json schema test suite
1 file changed
tree: a240e79ce8cc64209c1bf09bf6e51479e14a7f25
  1. doc/
  2. tests/
  3. .gitignore
  4. README.md
  5. schema.go
  6. schema_test.go
  7. schemaDocument.go
  8. schemaPool.go
  9. schemaType.go
  10. types.go
  11. validation.go
  12. validationutil.go
README.md

gojsonschema

Description

An implementation of JSON Schema, based on IETF's draft v4 - Go language

Status

Completed. Testing and debugging in progress ( 75% )

Usage

Basic example

package main 

import (
	"github.com/sigu-399/gojsonschema"
	"fmt"
)

func main() {

	schema, err := gojsonschema.NewJsonSchemaDocument("http://myhost/bla/schema1.json")
	// OR
	//schema, err := gojsonschema.NewJsonSchemaDocument("file:///home/me/myschemas/schema1.json")
	
	if err != nil {
		panic(err.Error())
	}

	jsonToValidate, err := gojsonschema.GetHttpJson("http://myotherhost/blu/extract56.json")
	// OR
	//jsonToValidate, err := gojsonschema.GetFileJson("file:///home/billy/hotels.json")
	
	if err != nil {
		panic(err.Error())
	}

	validationResult := schema.Validate(jsonToValidate)

	fmt.Printf("IsValid %v\n", validationResult.IsValid())
	fmt.Printf("%v\n", validationResult.GetErrorMessages())

}

References

###Website http://json-schema.org

###Schema Core http://json-schema.org/latest/json-schema-core.html

###Schema Validation http://json-schema.org/latest/json-schema-validation.html

Dependencies

https://github.com/sigu-399/gojsonpointer

https://github.com/sigu-399/gojsonreference