You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/2019-09/content/contentEncoding.markdown
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
keyword: "contentEncoding"
3
3
signature: "String"
4
-
value: This keyword should be set to a standard (to increase interoperability) encoding name such as those defined in [RFC 4648](https://www.rfc-editor.org/info/rfc4686)
4
+
value: This keyword should be set to a standard (to increase interoperability) encoding name such as those defined in [RFC 4648](https://www.rfc-editor.org/info/rfc4686) and [RFC 2045](https://www.rfc-editor.org/info/rfc2045.html)
5
5
summary: "The string instance should be interpreted as encoded binary data and decoded using the encoding named by this property."
Copy file name to clipboardExpand all lines: content/2020-12/content/contentEncoding.markdown
+49-9Lines changed: 49 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
keyword: "contentEncoding"
3
3
signature: "String"
4
-
value: This keyword should be set to a standard (to increase interoperability) encoding name such as those defined in [RFC 4648](https://www.rfc-editor.org/info/rfc4686)
4
+
value: This keyword should be set to a standard (to increase interoperability) encoding name such as those defined in [RFC 4648](https://www.rfc-editor.org/info/rfc4686) and [RFC 2045](https://www.rfc-editor.org/info/rfc2045.html)
5
5
summary: "The string instance should be interpreted as encoded binary data and decoded using the encoding named by this property."
6
6
kind: [ "annotation" ]
7
7
instance: [ "string" ]
@@ -20,19 +20,59 @@ related:
20
20
keyword: contentSchema
21
21
---
22
22
23
-
The `contentEncoding` keyword is an annotation used to specify the encoding used to store the contents of a string, particularly when it represents binary data. It indicates how the string value should be interpreted and decoded. This keyword is not directly involved in the validation process but provides metadata about the content.
23
+
The `contentEncoding` keyword signifies that an instance value (such as a
24
+
specific object property) should be considered binary data encoded into a JSON
25
+
string using the given encoding. This keyword does not affect validation, but
26
+
the evaluator will collect its value as an annotation. The use of this and
27
+
related keywords is a common technique to encode and describe arbitrary binary
28
+
data (such as image, audio, and video) in JSON.
24
29
25
-
*`contentEncoding` doesn't enforce strict validation. However, it's recommended to use it correctly to ensure compatibility with applications that might interpret the encoding.
26
-
* It represents the type of binary encoding used for the string under question. Some of the common encodings are listed [here](#common-encodings).
27
-
* The JSON Schema specification doesn't publish a predefined list of possible encodings
30
+
{{<best-practice>}}
28
31
29
-
## Common Encodings
32
+
It is recommended to set this keyword along with the [`contentMediaType`]({{<
33
+
ref "2020-12/content/contentmediatype" >}}) keyword to declare the type of data
34
+
being encoded (for example, an image in PNG format). Otherwise, the receiver
35
+
must treat the instance value as a binary blob without knowing for sure the
36
+
type of information it represents.
37
+
38
+
{{</best-practice>}}
39
+
40
+
{{<common-pitfall>}}
41
+
42
+
The JSON Schema specification prohibits implementations, for security reasons,
43
+
from automatically attempting to decode, parse, or validate encoded data
44
+
without the consumer explicitly opting in to such behaviour. If you require
45
+
this feature, consult the documentation of your tooling of choice to see if it
46
+
supports content encoding/decoding and how to enable it.
|`"base16"`| Encoding scheme for binary data using a 16-character hexadecimal alphabet |[RFC 4648 §8](https://datatracker.ietf.org/doc/html/rfc4648#section-8)|
34
-
|`"base32"`| Encoding scheme for binary data using a 32-character hexadecimal alphabet |[RFC 4648 §6](https://datatracker.ietf.org/doc/html/rfc4648#section-6)|
35
-
|`"base64"`| Encoding scheme for binary data using a 64-character hexadecimal alphabet |[RFC 4648 §4](https://datatracker.ietf.org/doc/html/rfc4648#section-4)|
71
+
|`"7bit"`| Encoding scheme that constrains ASCII to disallow octets greater than 127, disallow `NUL`, and restricts `CR` and `LF` to `CRLF` sequences |[RFC 2045 Section 2.7](https://datatracker.ietf.org/doc/html/rfc2045#section-2.7)|
72
+
|`"8bit"`| Encoding scheme that constrains ASCII to permit octets greater than 127, disallow `NUL`, and restrict `CR` and `LF` to `CRLF` sequences |[RFC 2045 Section 2.8](https://datatracker.ietf.org/doc/html/rfc2045#section-2.8)|
73
+
|`"binary"`| Encoding scheme where any sequence of octets is allowed |[RFC 2045 Section 2.9](https://datatracker.ietf.org/doc/html/rfc2045#section-2.9)|
74
+
|`"quoted-printable"`| Encoding scheme that preserves ASCII printable characters and escapes the rest using a simple algorithm based on an hexadecimal alphabet |[RFC 2045 Section 6.7](https://datatracker.ietf.org/doc/html/rfc2045#section-6.7)|
75
+
|`"base64"`| Encoding scheme using a 64-character hexadecimal alphabet |[RFC 2045 Section 6.8](https://datatracker.ietf.org/doc/html/rfc2045#section-6.8)|
Copy file name to clipboardExpand all lines: content/draft7/validation/contentEncoding.markdown
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
keyword: "contentEncoding"
3
3
signature: "String"
4
-
value: This keyword should be set to a standard (to increase interoperability) encoding name such as those defined in [RFC 4648](https://www.rfc-editor.org/info/rfc4686)
4
+
value: This keyword should be set to a standard (to increase interoperability) encoding name such as those defined in [RFC 4648](https://www.rfc-editor.org/info/rfc4686) and [RFC 2045](https://www.rfc-editor.org/info/rfc2045.html)
5
5
summary: "The string instance should be interpreted as encoded binary data and decoded using the encoding named by this property."
0 commit comments