9

can anyone give me an example of how to use the patternProperties item for json schema?

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

What I want to do in the json file is allow any subitem of "Example" that is starting with A e.g.:

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

is patternProperties the right choice for this?

jruizaranguren
  • 12,679
  • 7
  • 55
  • 73
Stephan
  • 1,639
  • 3
  • 15
  • 26

1 Answers1

12
{
  type: 'object',
  patternProperties: {
    '^A': {
      type: 'string',
      ...
    }
  }
}
Baggz
  • 17,207
  • 4
  • 37
  • 25