The following JSON object is valid:
{
"foo": "bar",
"pattern": "^(\/?[-a-zA-Z0-9_.]+)+$"
}
Whereas this one is not:
{
"foo": "bar",
"pattern": "^(\/?[-a-zA-Z0-9_.]+)+\.jpg$"
}
It's the escaped dot (\.
), but I can't see why this should not be valid JSON. I need to include such patterns in my real JSON schemas. The regexp there are far more complex and there is no way missing out on excaping, especially the dot.
BTW, escaping hypens in character classes such as in [a-z\-]
breaks validation as well.
How do I fix that?
Edit: I used http://jsonlint.com/, http://jsonvalidator.mytechlabs.com/ and a couple of node libraries.