Dictionary-like JSON schema

additionalProperties is your keyword:

{
    "type" : "object",
    "additionalProperties" : {
        "type" : "object",
        "required" : [
            "age",
            "gender"
        ],
        "properties" : {
            "age" : {
                "type" : "string"
            },
            "gender" : {
                "type" : "string"
            }
        }
    }
}

additionalProperties can have the following values with different meanings:

  • "additionalProperties": false No more properties are allowed at all.
  • "additionalProperties": true Other properties are allowed. This is the default behavior.
  • "additionalProperties": {"type": "string"} Additional properties (of arbitrary name) are allowed, as long as their value follows the given type ("string" here).
  • "additionalProperties": {*any schema*} Additional properties must satisfy the provided schema, such as the example provided above.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)