Skip to content

Instantly share code, notes, and snippets.

@hoxworth
Last active December 11, 2015 00:59
Show Gist options
  • Save hoxworth/4520717 to your computer and use it in GitHub Desktop.
Save hoxworth/4520717 to your computer and use it in GitHub Desktop.
Testing recursive JSON schema with a simple filesystem example.
{
"directory" : "/",
"entries" : [
{
"directory" : "var",
"entries" : [
"test.json",
"new.json"
]
},
"boot.log",
"blahblah.txt"
]
}
require 'json-schema'
JSON::Validator.validate('test.schema.json','test.json')
{
"id" : "directory",
"type" : "object",
"properties" : {
"directory" : { "type" : "string", "required" : true },
"entries" : {
"type" : "array",
"items" : {
"type" : [
{ "$ref" : "directory" },
{ "type" : "string" }
]
}
}
}
}
@coderextreme
Copy link

how would I generate the recursive JSON schema from a very large JSON document, like https://github.com/coderextreme/x3djson/blob/master/all.json.zip?raw=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment