19

What are the features present in the schema draft 4 that are not in the JSON schema draft 3 produced by IETF ?

Frank Schmitt
  • 30,195
  • 12
  • 73
  • 107
user2430996
  • 341
  • 1
  • 4
  • 12

2 Answers2

31

From the change logs:

New keywords

  • anyOf (match at least one schema in the schema array),
  • allOf (match all schemas in the schema array),
  • oneOf (match exactly one schema in the schema array),
  • not (do not match the schema),
  • multipleOf (replaces divisibleBy),
  • minProperties and maxProperties (the minimum and maximum number of members in an object instance),
  • definitions (standardized container for inlined subschemas).

Removed:

  • disallow
  • extends
  • divisbleBy

Changed in functionality:

Type

  • When the value is an array, schemas are no longer allowed as elements. Also, the array must have at least one element.

Before


{
    "type": [ "string", { "other": "schema" } ]
}

Now


{
   "anyOf": [
       { "type": "string" },
       { "other": "schema" }
    ]
}

Required

  • Before, it was an attribute of subschemas in properties. It is now a first level keyword playing the same role, and has a string array as an argument.

Before


{
    "properties": {
        "p": {
            "type": "string",
            "required": true
        },
        "q": {
            "type": "string",
            "required": true
        }
    }
}

Now


{
    "properties": {
        "p": { "type": "string" },
        "q": { "type": "string" }
    },
    "required": [ "p", "q" ]
}

Dependencies

  • A single string in a property dependency is no longer allowed, only arrays are allowed

Before


{
    "dependencies": { "a": "b" }
}

Now


{
    "dependencies": { "a": [ "b" ] }
}
hunterc
  • 1,957
  • 2
  • 15
  • 18
  • Thank you for this! I'm working on a pretty big project where json-schema is super important. It's going to be fun times when/if Json.Net ever decides to move from draft 3 to 4. – PercivalMcGullicuddy Jun 12 '14 at 01:15
6

If you're interested in a deep dive, you can review a diff between the two drafts on the IETF site.

However, if you're looking for a simpler summary of changes, Geraint Luff and Francis Galiegue created a changelog page on the project's github wiki that lists the changes, additions, and removals.

ezkl
  • 3,829
  • 23
  • 39