9

谁能给我一个如何将 patternProperties 项用于 json 模式的示例?

"Example" :
  "type" : "object",
  "patternProperties" :
  {
     <how do I use this>
  }

我想在 json 文件中做的是允许以 A 开头的“示例”的任何子项,例如:

{
  "Example" : 
  {
    "Aaa" : { ...}
  }
}

patternProperties 是正确的选择吗?

4

1 回答 1

12
{
  type: 'object',
  patternProperties: {
    '^A': {
      type: 'string',
      ...
    }
  }
}
于 2012-03-14T17:35:17.597 回答