Consider the following JSON :
{
"1234abcd" : {
"model" : "civic"
"made" : "toyota"
"year" : "2014"
}
}
consider another JSON :
{
"efgh56789" : {
"model" : "civic"
"made" : "toyota"
"year" : "2014"
}
}
the outermost alphanumeric key will vary and required, if the key was fixed; let's say "identifier" then the schema was straightforward, however since the key-name is variable, we have to use patternProperties
, how can I come up with a schema that captures these requirement for the outermost key:
- property name (key) is variable
- required
- alphanumeric lowercase
using json-schema : https://github.com/ruby-json-schema/json-schema in ruby.
You may have to change the regular expression to fit your valid keys: