Format

The format keyword allows for basic semantic identification of certain kinds of string values that are commonly used.

For example, because JSON doesn't have a "DateTime" type, dates need to be encoded as strings. format allows the schema author to indicate that the string value should be interpreted as a date.

Some common formats include:

  • Date and time formats: date-time, date, time, duration
  • Email formats: email, idn-email
  • Hostname formats: hostname, idn-hostname
  • IP address formats: ipv4, ipv6
  • Resource identifier formats: uuid, uri, uri-reference, iri, iri-reference

View more about the formats here

1{
2  "type": "string",
3  "format": "date-time"
4}

Examples

The examples keyword is used to provide an array of example values that are valid against the schema.

1{
2  "type": "string",
3  "format":"date",
4  "examples": ["2021-12-31", "2022-01-01"]
5}

Task

1{
2  "name": "John Doe",
3  "email": "[email protected]"
4}

You are given a schema of the above JSON object in the side editor.

  • Add a format to the email property.
  • Add examples to the email property.
Loading...
Output
Please click the button or use
Shift+Enter
to view the output