contentMediaType : String
contentMediaType
StringThis keyword declares the media type of the string instance.
Value | This keyword should be set to a valid media type as defined in RFC 2046, like the registered IANA media types |
---|---|
Kind | Annotation |
Applies To | String |
Dialect | 2020-12 |
Changed In | None |
Introduced In | Draft 7 |
Vocabulary | Content |
Specification | https://json-schema.org/draft/2020-12/json-schema-validation.html#section-8.4 |
Metaschema | https://json-schema.org/draft/2020-12/meta/content |
Official Tests | draft2020-12/content.json |
Default | None |
Annotation | String The content media type set by this keyword |
Affected By | None |
Affects |
|
Also See |
|
The contentMediaType
keyword in JSON Schema specifies the MIME type of the contents of a string. It is used to annotate the type of media contained within a string. It should be noted that:
- This keyword is purely an annotation and does not directly affect validation.
- It describes the media type of the binary string after it has been decoded as specified in
contentEncoding
. - It is recommended to set
contentEncoding
ifcontentMediaType
is declared.
Examples
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentEncoding": "base64",
"contentMediaType": "application/json"
}
"eyAibmFtZSI6ICJKb2huIERvZSIgfQ==" // --> { "name": "John Doe" }
"eyAibmFtZSI6IH0=" // --> { "name": }
true
{ "keyword": "/contentEncoding", "instance": "", "value": "base64" }
{ "keyword": "/contentMediaType", "instance": "", "value": "application/json" }