On json-schema.org you will find something appropriate in the Advanced Examples section. You can define patternProperties
inside an object
.
{
"type": "object",
"properties": {
"/": {}
},
"patternProperties": {
"^(label_name_[0-9]+)+$": { "type": "integer" }
},
"additionalProperties": false,
}
The regular expression (label_name_[0-9]+)+
should fit your needs. In JSON Schema regular expressions are explicitly anchored with ^
and $
. The regular expressions defines, that there has to be at least one property (+
). The property consists of label_name_
and a number between 0
and 9
whereas there has to be at least one number ([0-9]+)
, but there can also arbitrary many of them.
By setting additionalProperties
to false
it constrains object properties to match the regular expression.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…