Last active
December 11, 2015 00:59
-
-
Save hoxworth/4520717 to your computer and use it in GitHub Desktop.
Testing recursive JSON schema with a simple filesystem example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"directory" : "/", | |
"entries" : [ | |
{ | |
"directory" : "var", | |
"entries" : [ | |
"test.json", | |
"new.json" | |
] | |
}, | |
"boot.log", | |
"blahblah.txt" | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json-schema' | |
JSON::Validator.validate('test.schema.json','test.json') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id" : "directory", | |
"type" : "object", | |
"properties" : { | |
"directory" : { "type" : "string", "required" : true }, | |
"entries" : { | |
"type" : "array", | |
"items" : { | |
"type" : [ | |
{ "$ref" : "directory" }, | |
{ "type" : "string" } | |
] | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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