Skip to content

Instantly share code, notes, and snippets.

@justinanderson
Created September 6, 2013 16:09
Show Gist options
  • Select an option

  • Save justinanderson/6466049 to your computer and use it in GitHub Desktop.

Select an option

Save justinanderson/6466049 to your computer and use it in GitHub Desktop.
This is an example of how JSON schema allows for deceptive schema. bad-schema.json looks like it requires an array to contain only strings, but in truth it only checks the first element of the array, so both bad.json and good.json validate against bad-schema.json. good-schema.json validates every element of the array, so good.json validates agai…
{
"type": "array",
"items": [
{
"type": "string"
}
]
}
[
"1", 5, null
]
{
"type": "array",
"items": {
"type": "string"
}
}
[
"1", "5", "null"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment