JSON Schema with unknown property names

Use patternProperties instead of properties. In the example below, the pattern match regex .* accepts any property name and I am allowing types of string or null only by using "additionalProperties": false.

  "patternProperties": {
    "^.*$": {
      "anyOf": [
        {"type": "string"},
        {"type": "null"}
      ]
    }
  },
  "additionalProperties": false

… or if you just want to allow a string in your “object” (like in the original question):

  "patternProperties": {
    "^.*$": {
        {"type": "string"},
    }
  },
  "additionalProperties": false

Leave a Comment

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