Skip to content

About

JSON Schema in Go

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

228 Commits

Folders and files

Repository files navigation

Json Schema using Brzozowski's derivatives

JSON Schema in Go using Katydid underlying algorithm. This project translates JSON Schema to a regular hedge grammar and then executes validation via Katydid's validator-go.

Usage Example

import (
    "katydid.org.za/go/validator-go-jsonschema/jsonschema"
)

func main() {
	schemaBytes := []byte(`
    { "title": "small jsonschema for a blogpost",
      "type":"object", "additionalProperties":false, "required": ["content"],
      "properties": {
        "content": { "type":"string" },
        "author": { "$ref":"#/definitions/user-profile" } },
      "definitions": { "user-profile": {
        "type": "object", "additionalProperties":false, "required": ["username"], 
        "properties": {
          "username": { "type":"string" },
          "email": { "type":"string", "format":"email" } } } } }`)
	compiled, err := jsonschema.Compile(schemaBytes)
	...
	input := []byte(`{"content": "Dragons", "author": {"username": "Khaleesi"}}`)
	matched, err := compiled.MatchBytes(input)
	...
}

Test Suites passed

  • Draft4 (excluding uniqueItems and remoteRef)

Unsupported

About

JSON Schema in Go

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages