Media: string-encoding non-JSON data¶
JSON schema has a set of keywords to describe and optionally validate non-JSON data stored inside JSON strings. Since it would be difficult to write validators for many media types, JSON schema validators are not required to validate the contents of JSON strings based on these keywords. However, these keywords are still useful for an application that consumes validated JSON.
contentMediaType keyword specifies the MIME type of the contents
of a string, as described in RFC 2046.
There is a list of MIME types officially registered by the IANA,
but the set of types supported will be application and operating system dependent.
Mozilla Developer Network also maintains a shorter list of MIME types that are important for the web
The acceptable values are
base64. If not specified, the encoding is the
same as the containing JSON document.
Without getting into the low-level details of each of these encodings, there are really only two options useful for modern usage:
- If the content is encoded in the same encoding as the enclosing JSON
document (which for practical purposes, is almost always UTF-8),
contentEncodingunspecified, and include the content in a string as-is. This includes text-based content types, such as
- If the content is binary data, set
base64and encode the contents using Base64. This would include many image types, such as
image/pngor audio types, such as
Documentation Coming soon
The following schema indicates the string contains an HTML document, encoded using the same encoding as the surrounding document:
The following schema indicates that a string contains a PNG image, encoded using Base64: