Description
Most regular/context-free grammars that are a subset of JSON documents have an equivalent representation in JSON Schema. However there's some kinds of JSON arrays that can be specified with a regular expression, but that has no JSON Schema equivalent. For example, an array whose items are an odd number of positive integers, then a boolean:
/^\[[1-9][0-9]*, ([1-9][0-9]*, [1-9][0-9]*, )* (true|false)\]$/
(Some whitespace/decimal forms supported in JSON is removed here for brevity; it is more complicated, but suffice to say it exists.)
In order to be able to convert between a regular/context-free language and JSON Schema, there needs to be some keywords that can implement the "array" counterparts to regular expressions in strings:
- "concat", to concatenate multiple grammars together, specified by an array of subschemas.
- "someOf", to describe alternation (validates if one or more of the subschemas is valid).
- "repeatMin"/"repeatMax", to describe repetition and the Kleene star.
I was trying to spec out a hierarchy of JSON Schema features (mostly by processing & memory complexity), and I realized array items with regular patterns was missing from the O(n) complexity class.
The lack of feedback relating to this sort of thing suggests this would have limited usefulness as a core requirement, but I'd like to describe it here for completeness. The only instance I can think of are arrays where even items represent a name, and odd items represent the value. Node.js describes raw HTTP headers this way.