Skip to content

Nested objects with unknown keys - how to specify? #399

Closed Answered by gregsdennis
mgrosvenor asked this question in Q&A
Discussion options

You must be logged in to vote

I think you want to just specify additionalProperties, which just takes a schema. Often the false schema is used to indicate that there should be no properties other than the ones specified by the schema, but if you have arbitrary keys where the values must all be the same shape, then you can put the schema for the values in this.

{
  "type": "object",
  "additionalProperties": { ... }
}

The meta-schemas actually do this for a number of properties, like $defs and properties where the keys can be anything, but the values need to be valid schemas.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mgrosvenor
Comment options

Answer selected by mgrosvenor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants