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: README.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
This document describes a simple [JSON Schema vocabulary](https://json-schema.org/draft/2020-12/json-schema-core.html#name-schema-vocabularies) that can be used to validate JSON text sequences as specified by [RFC 7464](https://datatracker.ietf.org/doc/html/rfc7464).
6
6
7
-
It defines two keywords which allow applying a JSON schema to individual elements in a JSON text sequence (hereafter "sequence").
7
+
It defines two keywords which allow applying a JSON schema to individual elements in a JSON text sequence (hereafter "sequence") and producing an annotation of the element-wise result of application of the schema.
8
8
9
9
Though indeed the entirety of a sequence is not itself a standard JSON type (nor valid JSON), proscribed below is a loose [`stream` type](#streams) whose implementation is left mostly to the specific language or implementation to further define.
10
10
@@ -19,13 +19,13 @@ The `$id` for the meta-schema is `https://python-jsonschema.github.io/vocab-json
19
19
20
20
### 3.1 Syntax and Semantics
21
21
22
-
The value of the `jsonseq` keyword MUST be a valid JSON Schema.
22
+
The `jsonseq` keyword is a JSON Schema [annotation](https://json-schema.org/draft/2020-12/json-schema-core.html#name-annotations) whose value MUST be a valid JSON Schema.
23
23
24
-
This schema, when applied to a sequence, MUST be evaluated against each sequence element.
25
-
The result of this evaluation is an annotation which itself is a stream.
26
-
The elements of this annotation MUST be the corresponding validation result for each element in the sequence.
24
+
Applying the keyword to a stream instance MUST produce a single annotation result, itself a new stream.
25
+
The contents of the annotation stream MUST be the corresponding result of applying the schema element-wise to each element of the sequence.
27
26
28
-
Validating a non-stream instance against this keyword always succeeds.
27
+
Validating an empty stream against this keyword (one which contains no elements) produces an empty stream annotation, as does validating a non-stream instance.
28
+
(As discussed [below](#
29
29
30
30
### 3.2 Contextual Behavior
31
31
@@ -45,10 +45,16 @@ The processing of the `jsonseq` keyword, or truthfully of JSON Text Sequences th
45
45
46
46
This document does not define the specific implementation of streams. A programming language or implementation with lazy iterable support SHOULD represent streams using this language feature.
47
47
48
-
The core JSON vocabulary [does not allow](https://json-schema.org/draft/2020-12/json-schema-core.html#name-instance-data-model) external vocabularies to define additional types via the `type` keyword.
48
+
Implementations MUST also consider JSON `array` values to be streams for the purpose of the keywords defined in this vocabulary.
49
+
50
+
Schema authors who do not wish to allow `array` valued instances are RECOMMENDED to use existing JSON Schema mechanisms to exclude them (e.g. `{"not": {"type": "array"}}`).
51
+
52
+
The core JSON vocabulary [does not allow](https://json-schema.org/draft/2020-12/json-schema-core.html#name-instance-data-model) external vocabularies to define additional data types via the `type` keyword.
49
53
It does however [allow](https://json-schema.org/draft/2020-12/json-schema-core.html#name-non-json-instances) for the application of JSON Schema to types beyond those provided by JSON.
50
54
A `streamType` keyword is therefore introduced below, which can be used to assert a value is a stream in the sense defined here.
51
55
56
+
(Editor's note: the definition of `streamType` may be moved to a separate vocabulary in the future).
57
+
52
58
### 4.2 The `streamType` Keyword
53
59
54
60
The value of the `streamType` keyword MUST be a boolean, or the value `null`.
@@ -57,12 +63,6 @@ When `true`, validation MUST succeed if the instance is a stream, and fail other
57
63
When `false`, validation MUST fail if the instance is a stream, and succeed otherwise.
58
64
When `null`, validation always succeeds.
59
65
60
-
Implementations MUST also consider JSON `array` values to be streams for the purpose of the keywords defined in this vocabulary.
61
-
62
-
Schema authors who do not wish to allow `array` valued instances are RECOMMENDED to use existing JSON Schema mechanisms to exclude them (e.g. `{"not": {"type": "array"}}`).
63
-
64
-
(Editor's note: the definition of `streamType` may be moved to a separate vocabulary in the future).
65
-
66
66
## 5. A Short Example
67
67
68
68
Consider the following schema, utilizing the two keywords above, which asserts that elements of a sequence are objects whose `foo` property is an integer at most 10:
0 commit comments