@toon-format/spec 1.3.3 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +3 -3
- package/SPEC.md +252 -100
- package/VERSIONING.md +0 -13
- package/package.json +1 -1
- package/tests/README.md +27 -23
- package/tests/fixtures/decode/arrays-nested.json +20 -20
- package/tests/fixtures/decode/arrays-primitive.json +14 -14
- package/tests/fixtures/decode/arrays-tabular.json +28 -5
- package/tests/fixtures/decode/blank-lines.json +14 -14
- package/tests/fixtures/decode/delimiters.json +46 -29
- package/tests/fixtures/decode/indentation-errors.json +16 -29
- package/tests/fixtures/decode/numbers.json +142 -0
- package/tests/fixtures/decode/objects.json +29 -29
- package/tests/fixtures/decode/primitives.json +44 -75
- package/tests/fixtures/decode/root-form.json +17 -0
- package/tests/fixtures/decode/validation-errors.json +29 -9
- package/tests/fixtures/decode/whitespace.json +61 -0
- package/tests/fixtures/encode/arrays-nested.json +15 -15
- package/tests/fixtures/encode/arrays-objects.json +16 -16
- package/tests/fixtures/encode/arrays-primitive.json +14 -14
- package/tests/fixtures/encode/arrays-tabular.json +8 -8
- package/tests/fixtures/encode/delimiters.json +23 -23
- package/tests/fixtures/encode/objects.json +27 -27
- package/tests/fixtures/encode/options.json +1 -1
- package/tests/fixtures/encode/primitives.json +61 -36
- package/tests/fixtures/encode/whitespace.json +18 -3
- package/tests/fixtures.schema.json +3 -4
- package/tests/fixtures/encode/normalization.json +0 -107
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.4",
|
|
3
3
|
"category": "decode",
|
|
4
4
|
"description": "Object decoding - simple objects, nested objects, key parsing, quoted values",
|
|
5
5
|
"tests": [
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"name": "Ada",
|
|
12
12
|
"active": true
|
|
13
13
|
},
|
|
14
|
-
"specSection": "
|
|
14
|
+
"specSection": "8"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
"name": "parses null values in objects",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"id": 123,
|
|
21
21
|
"value": null
|
|
22
22
|
},
|
|
23
|
-
"specSection": "
|
|
23
|
+
"specSection": "8"
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
"name": "parses empty nested object header",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"expected": {
|
|
29
29
|
"user": {}
|
|
30
30
|
},
|
|
31
|
-
"specSection": "
|
|
31
|
+
"specSection": "8"
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
"name": "parses quoted object value with colon",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"expected": {
|
|
37
37
|
"note": "a:b"
|
|
38
38
|
},
|
|
39
|
-
"specSection": "
|
|
39
|
+
"specSection": "8"
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"name": "parses quoted object value with comma",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"expected": {
|
|
45
45
|
"note": "a,b"
|
|
46
46
|
},
|
|
47
|
-
"specSection": "
|
|
47
|
+
"specSection": "8"
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
"name": "parses quoted object value with newline escape",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"expected": {
|
|
53
53
|
"text": "line1\nline2"
|
|
54
54
|
},
|
|
55
|
-
"specSection": "
|
|
55
|
+
"specSection": "8"
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"name": "parses quoted object value with escaped quotes",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"expected": {
|
|
61
61
|
"text": "say \"hello\""
|
|
62
62
|
},
|
|
63
|
-
"specSection": "
|
|
63
|
+
"specSection": "8"
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
"name": "parses quoted object value with leading/trailing spaces",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"expected": {
|
|
69
69
|
"text": " padded "
|
|
70
70
|
},
|
|
71
|
-
"specSection": "
|
|
71
|
+
"specSection": "8"
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
"name": "parses quoted object value with only spaces",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"expected": {
|
|
77
77
|
"text": " "
|
|
78
78
|
},
|
|
79
|
-
"specSection": "
|
|
79
|
+
"specSection": "8"
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
82
|
"name": "parses quoted string value that looks like true",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"expected": {
|
|
85
85
|
"v": "true"
|
|
86
86
|
},
|
|
87
|
-
"specSection": "
|
|
87
|
+
"specSection": "8"
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
90
|
"name": "parses quoted string value that looks like integer",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"expected": {
|
|
93
93
|
"v": "42"
|
|
94
94
|
},
|
|
95
|
-
"specSection": "
|
|
95
|
+
"specSection": "8"
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
"name": "parses quoted string value that looks like negative decimal",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"expected": {
|
|
101
101
|
"v": "-7.5"
|
|
102
102
|
},
|
|
103
|
-
"specSection": "
|
|
103
|
+
"specSection": "8"
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
106
|
"name": "parses quoted key with colon",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"expected": {
|
|
109
109
|
"order:id": 7
|
|
110
110
|
},
|
|
111
|
-
"specSection": "
|
|
111
|
+
"specSection": "8"
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
114
|
"name": "parses quoted key with brackets",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"expected": {
|
|
117
117
|
"[index]": 5
|
|
118
118
|
},
|
|
119
|
-
"specSection": "
|
|
119
|
+
"specSection": "8"
|
|
120
120
|
},
|
|
121
121
|
{
|
|
122
122
|
"name": "parses quoted key with braces",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"expected": {
|
|
125
125
|
"{key}": 5
|
|
126
126
|
},
|
|
127
|
-
"specSection": "
|
|
127
|
+
"specSection": "8"
|
|
128
128
|
},
|
|
129
129
|
{
|
|
130
130
|
"name": "parses quoted key with comma",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"expected": {
|
|
133
133
|
"a,b": 1
|
|
134
134
|
},
|
|
135
|
-
"specSection": "
|
|
135
|
+
"specSection": "8"
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
"name": "parses quoted key with spaces",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"expected": {
|
|
141
141
|
"full name": "Ada"
|
|
142
142
|
},
|
|
143
|
-
"specSection": "
|
|
143
|
+
"specSection": "8"
|
|
144
144
|
},
|
|
145
145
|
{
|
|
146
146
|
"name": "parses quoted key with leading hyphen",
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
"expected": {
|
|
149
149
|
"-lead": 1
|
|
150
150
|
},
|
|
151
|
-
"specSection": "
|
|
151
|
+
"specSection": "8"
|
|
152
152
|
},
|
|
153
153
|
{
|
|
154
154
|
"name": "parses quoted key with leading and trailing spaces",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"expected": {
|
|
157
157
|
" a ": 1
|
|
158
158
|
},
|
|
159
|
-
"specSection": "
|
|
159
|
+
"specSection": "8"
|
|
160
160
|
},
|
|
161
161
|
{
|
|
162
162
|
"name": "parses quoted numeric key",
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
"expected": {
|
|
165
165
|
"123": "x"
|
|
166
166
|
},
|
|
167
|
-
"specSection": "
|
|
167
|
+
"specSection": "8"
|
|
168
168
|
},
|
|
169
169
|
{
|
|
170
170
|
"name": "parses quoted empty string key",
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
"expected": {
|
|
173
173
|
"": 1
|
|
174
174
|
},
|
|
175
|
-
"specSection": "
|
|
175
|
+
"specSection": "8"
|
|
176
176
|
},
|
|
177
177
|
{
|
|
178
178
|
"name": "parses dotted keys as identifiers",
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
"expected": {
|
|
181
181
|
"user.name": "Ada"
|
|
182
182
|
},
|
|
183
|
-
"specSection": "
|
|
183
|
+
"specSection": "8"
|
|
184
184
|
},
|
|
185
185
|
{
|
|
186
186
|
"name": "parses underscore-prefixed keys",
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
"expected": {
|
|
189
189
|
"_private": 1
|
|
190
190
|
},
|
|
191
|
-
"specSection": "
|
|
191
|
+
"specSection": "8"
|
|
192
192
|
},
|
|
193
193
|
{
|
|
194
194
|
"name": "parses underscore-containing keys",
|
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
"expected": {
|
|
197
197
|
"user_name": 1
|
|
198
198
|
},
|
|
199
|
-
"specSection": "
|
|
199
|
+
"specSection": "8"
|
|
200
200
|
},
|
|
201
201
|
{
|
|
202
202
|
"name": "unescapes newline in key",
|
|
@@ -204,7 +204,7 @@
|
|
|
204
204
|
"expected": {
|
|
205
205
|
"line\nbreak": 1
|
|
206
206
|
},
|
|
207
|
-
"specSection": "
|
|
207
|
+
"specSection": "8"
|
|
208
208
|
},
|
|
209
209
|
{
|
|
210
210
|
"name": "unescapes tab in key",
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
"expected": {
|
|
213
213
|
"tab\there": 2
|
|
214
214
|
},
|
|
215
|
-
"specSection": "
|
|
215
|
+
"specSection": "8"
|
|
216
216
|
},
|
|
217
217
|
{
|
|
218
218
|
"name": "unescapes quotes in key",
|
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
"expected": {
|
|
221
221
|
"he said \"hi\"": 1
|
|
222
222
|
},
|
|
223
|
-
"specSection": "
|
|
223
|
+
"specSection": "8"
|
|
224
224
|
},
|
|
225
225
|
{
|
|
226
226
|
"name": "parses deeply nested objects with indentation",
|
|
@@ -232,7 +232,7 @@
|
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
},
|
|
235
|
-
"specSection": "
|
|
235
|
+
"specSection": "8"
|
|
236
236
|
}
|
|
237
237
|
]
|
|
238
238
|
}
|
|
@@ -1,189 +1,158 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.4",
|
|
3
3
|
"category": "decode",
|
|
4
4
|
"description": "Primitive value decoding - strings, numbers, booleans, null, unescaping",
|
|
5
5
|
"tests": [
|
|
6
6
|
{
|
|
7
|
-
"name": "
|
|
7
|
+
"name": "parses safe unquoted string",
|
|
8
8
|
"input": "hello",
|
|
9
9
|
"expected": "hello",
|
|
10
|
-
"specSection": "
|
|
10
|
+
"specSection": "7.4"
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
|
-
"name": "
|
|
13
|
+
"name": "parses unquoted string with underscore and numbers",
|
|
14
14
|
"input": "Ada_99",
|
|
15
15
|
"expected": "Ada_99",
|
|
16
|
-
"specSection": "
|
|
16
|
+
"specSection": "7.4"
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
|
-
"name": "
|
|
19
|
+
"name": "parses empty quoted string",
|
|
20
20
|
"input": "\"\"",
|
|
21
21
|
"expected": "",
|
|
22
|
-
"specSection": "
|
|
22
|
+
"specSection": "7.4"
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
"name": "
|
|
25
|
+
"name": "parses quoted string with newline escape",
|
|
26
26
|
"input": "\"line1\\nline2\"",
|
|
27
27
|
"expected": "line1\nline2",
|
|
28
|
-
"specSection": "
|
|
28
|
+
"specSection": "7.1"
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
|
-
"name": "
|
|
31
|
+
"name": "parses quoted string with tab escape",
|
|
32
32
|
"input": "\"tab\\there\"",
|
|
33
33
|
"expected": "tab\there",
|
|
34
|
-
"specSection": "
|
|
34
|
+
"specSection": "7.1"
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
|
-
"name": "
|
|
37
|
+
"name": "parses quoted string with carriage return escape",
|
|
38
38
|
"input": "\"return\\rcarriage\"",
|
|
39
39
|
"expected": "return\rcarriage",
|
|
40
|
-
"specSection": "
|
|
40
|
+
"specSection": "7.1"
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
|
-
"name": "
|
|
43
|
+
"name": "parses quoted string with backslash escape",
|
|
44
44
|
"input": "\"C:\\\\Users\\\\path\"",
|
|
45
45
|
"expected": "C:\\Users\\path",
|
|
46
|
-
"specSection": "
|
|
46
|
+
"specSection": "7.1"
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
|
-
"name": "
|
|
49
|
+
"name": "parses quoted string with escaped quotes",
|
|
50
50
|
"input": "\"say \\\"hello\\\"\"",
|
|
51
51
|
"expected": "say \"hello\"",
|
|
52
|
-
"specSection": "
|
|
52
|
+
"specSection": "7.1"
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
|
-
"name": "
|
|
55
|
+
"name": "parses Unicode string",
|
|
56
56
|
"input": "café",
|
|
57
57
|
"expected": "café",
|
|
58
|
-
"specSection": "
|
|
58
|
+
"specSection": "7.4"
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
|
-
"name": "
|
|
61
|
+
"name": "parses Chinese characters",
|
|
62
62
|
"input": "你好",
|
|
63
63
|
"expected": "你好",
|
|
64
|
-
"specSection": "
|
|
64
|
+
"specSection": "7.4"
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
|
-
"name": "
|
|
67
|
+
"name": "parses emoji",
|
|
68
68
|
"input": "🚀",
|
|
69
69
|
"expected": "🚀",
|
|
70
|
-
"specSection": "
|
|
70
|
+
"specSection": "7.4"
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
|
-
"name": "
|
|
73
|
+
"name": "parses string with emoji and spaces",
|
|
74
74
|
"input": "hello 👋 world",
|
|
75
75
|
"expected": "hello 👋 world",
|
|
76
|
-
"specSection": "
|
|
76
|
+
"specSection": "7.4"
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
|
-
"name": "
|
|
79
|
+
"name": "parses positive integer",
|
|
80
80
|
"input": "42",
|
|
81
81
|
"expected": 42,
|
|
82
|
-
"specSection": "
|
|
82
|
+
"specSection": "4"
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
|
-
"name": "
|
|
85
|
+
"name": "parses decimal number",
|
|
86
86
|
"input": "3.14",
|
|
87
87
|
"expected": 3.14,
|
|
88
|
-
"specSection": "
|
|
88
|
+
"specSection": "4"
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
|
-
"name": "
|
|
91
|
+
"name": "parses negative integer",
|
|
92
92
|
"input": "-7",
|
|
93
93
|
"expected": -7,
|
|
94
|
-
"specSection": "
|
|
94
|
+
"specSection": "4"
|
|
95
95
|
},
|
|
96
96
|
{
|
|
97
|
-
"name": "
|
|
97
|
+
"name": "parses true",
|
|
98
98
|
"input": "true",
|
|
99
99
|
"expected": true,
|
|
100
|
-
"specSection": "
|
|
100
|
+
"specSection": "4"
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
|
-
"name": "
|
|
103
|
+
"name": "parses false",
|
|
104
104
|
"input": "false",
|
|
105
105
|
"expected": false,
|
|
106
|
-
"specSection": "
|
|
106
|
+
"specSection": "4"
|
|
107
107
|
},
|
|
108
108
|
{
|
|
109
|
-
"name": "
|
|
109
|
+
"name": "parses null",
|
|
110
110
|
"input": "null",
|
|
111
111
|
"expected": null,
|
|
112
|
-
"specSection": "
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
"name": "treats unquoted leading-zero number as string",
|
|
116
|
-
"input": "05",
|
|
117
|
-
"expected": "05",
|
|
118
|
-
"specSection": "5",
|
|
119
|
-
"note": "Leading zeros make it a string"
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
"name": "treats unquoted multi-leading-zero as string",
|
|
123
|
-
"input": "007",
|
|
124
|
-
"expected": "007",
|
|
125
|
-
"specSection": "5"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"name": "treats unquoted octal-like as string",
|
|
129
|
-
"input": "0123",
|
|
130
|
-
"expected": "0123",
|
|
131
|
-
"specSection": "5"
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
"name": "treats leading-zero in object value as string",
|
|
135
|
-
"input": "a: 05",
|
|
136
|
-
"expected": { "a": "05" },
|
|
137
|
-
"specSection": "5"
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
"name": "treats leading-zeros in array as strings",
|
|
141
|
-
"input": "nums[3]: 05,007,0123",
|
|
142
|
-
"expected": { "nums": ["05", "007", "0123"] },
|
|
143
|
-
"specSection": "5"
|
|
112
|
+
"specSection": "4"
|
|
144
113
|
},
|
|
145
114
|
{
|
|
146
115
|
"name": "respects ambiguity quoting for true",
|
|
147
116
|
"input": "\"true\"",
|
|
148
117
|
"expected": "true",
|
|
149
|
-
"specSection": "
|
|
118
|
+
"specSection": "7.4",
|
|
150
119
|
"note": "Quoted primitive remains string"
|
|
151
120
|
},
|
|
152
121
|
{
|
|
153
122
|
"name": "respects ambiguity quoting for false",
|
|
154
123
|
"input": "\"false\"",
|
|
155
124
|
"expected": "false",
|
|
156
|
-
"specSection": "
|
|
125
|
+
"specSection": "7.4"
|
|
157
126
|
},
|
|
158
127
|
{
|
|
159
128
|
"name": "respects ambiguity quoting for null",
|
|
160
129
|
"input": "\"null\"",
|
|
161
130
|
"expected": "null",
|
|
162
|
-
"specSection": "
|
|
131
|
+
"specSection": "7.4"
|
|
163
132
|
},
|
|
164
133
|
{
|
|
165
134
|
"name": "respects ambiguity quoting for integer",
|
|
166
135
|
"input": "\"42\"",
|
|
167
136
|
"expected": "42",
|
|
168
|
-
"specSection": "
|
|
137
|
+
"specSection": "7.4"
|
|
169
138
|
},
|
|
170
139
|
{
|
|
171
140
|
"name": "respects ambiguity quoting for negative decimal",
|
|
172
141
|
"input": "\"-3.14\"",
|
|
173
142
|
"expected": "-3.14",
|
|
174
|
-
"specSection": "
|
|
143
|
+
"specSection": "7.4"
|
|
175
144
|
},
|
|
176
145
|
{
|
|
177
146
|
"name": "respects ambiguity quoting for scientific notation",
|
|
178
147
|
"input": "\"1e-6\"",
|
|
179
148
|
"expected": "1e-6",
|
|
180
|
-
"specSection": "
|
|
149
|
+
"specSection": "7.4"
|
|
181
150
|
},
|
|
182
151
|
{
|
|
183
152
|
"name": "respects ambiguity quoting for leading-zero",
|
|
184
153
|
"input": "\"05\"",
|
|
185
154
|
"expected": "05",
|
|
186
|
-
"specSection": "
|
|
155
|
+
"specSection": "7.4"
|
|
187
156
|
}
|
|
188
157
|
]
|
|
189
158
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.4",
|
|
3
|
+
"category": "decode",
|
|
4
|
+
"description": "Root form detection - empty document, single primitive, multiple primitives",
|
|
5
|
+
"tests": [
|
|
6
|
+
{
|
|
7
|
+
"name": "empty document decodes to empty object",
|
|
8
|
+
"input": "",
|
|
9
|
+
"expected": {},
|
|
10
|
+
"options": {
|
|
11
|
+
"strict": true
|
|
12
|
+
},
|
|
13
|
+
"specSection": "5",
|
|
14
|
+
"note": "Empty input (no non-empty lines) decodes to empty object"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.4",
|
|
3
3
|
"category": "decode",
|
|
4
4
|
"description": "Validation errors - length mismatches, invalid escapes, syntax errors, delimiter mismatches",
|
|
5
5
|
"tests": [
|
|
@@ -8,56 +8,76 @@
|
|
|
8
8
|
"input": "tags[2]: a,b,c",
|
|
9
9
|
"expected": null,
|
|
10
10
|
"shouldError": true,
|
|
11
|
-
"specSection": "
|
|
11
|
+
"specSection": "14.1"
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
"name": "throws on array length mismatch (list format - too many)",
|
|
15
15
|
"input": "items[1]:\n - 1\n - 2",
|
|
16
16
|
"expected": null,
|
|
17
17
|
"shouldError": true,
|
|
18
|
-
"specSection": "
|
|
18
|
+
"specSection": "14.1"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"name": "throws when tabular row value count does not match header field count",
|
|
22
22
|
"input": "items[2]{id,name}:\n 1,Ada\n 2",
|
|
23
23
|
"expected": null,
|
|
24
24
|
"shouldError": true,
|
|
25
|
-
"specSection": "
|
|
25
|
+
"specSection": "14.1"
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
"name": "throws when tabular row count does not match header length",
|
|
29
29
|
"input": "[1]{id}:\n 1\n 2",
|
|
30
30
|
"expected": null,
|
|
31
31
|
"shouldError": true,
|
|
32
|
-
"specSection": "
|
|
32
|
+
"specSection": "14.1"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"name": "throws on invalid escape sequence",
|
|
36
36
|
"input": "\"a\\x\"",
|
|
37
37
|
"expected": null,
|
|
38
38
|
"shouldError": true,
|
|
39
|
-
"specSection": "
|
|
39
|
+
"specSection": "14.2"
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"name": "throws on unterminated string",
|
|
43
43
|
"input": "\"unterminated",
|
|
44
44
|
"expected": null,
|
|
45
45
|
"shouldError": true,
|
|
46
|
-
"specSection": "
|
|
46
|
+
"specSection": "14.2"
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
"name": "throws on missing colon in key-value context",
|
|
50
50
|
"input": "a:\n user",
|
|
51
51
|
"expected": null,
|
|
52
52
|
"shouldError": true,
|
|
53
|
-
"specSection": "
|
|
53
|
+
"specSection": "14.2"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "throws on two primitives at root depth in strict mode",
|
|
57
|
+
"input": "hello\nworld",
|
|
58
|
+
"expected": null,
|
|
59
|
+
"shouldError": true,
|
|
60
|
+
"options": {
|
|
61
|
+
"strict": true
|
|
62
|
+
},
|
|
63
|
+
"specSection": "5"
|
|
54
64
|
},
|
|
55
65
|
{
|
|
56
66
|
"name": "throws on delimiter mismatch (header declares tab, row uses comma)",
|
|
57
67
|
"input": "items[2\t]{a\tb}:\n 1,2\n 3,4",
|
|
58
68
|
"expected": null,
|
|
59
69
|
"shouldError": true,
|
|
60
|
-
"specSection": "
|
|
70
|
+
"specSection": "14.2"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"name": "throws on mismatched delimiter between bracket and brace fields",
|
|
74
|
+
"input": "items[2\t]{a,b}:\n 1\t2\n 3\t4",
|
|
75
|
+
"expected": null,
|
|
76
|
+
"shouldError": true,
|
|
77
|
+
"options": {
|
|
78
|
+
"strict": true
|
|
79
|
+
},
|
|
80
|
+
"specSection": "6"
|
|
61
81
|
}
|
|
62
82
|
]
|
|
63
83
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.4",
|
|
3
|
+
"category": "decode",
|
|
4
|
+
"description": "Whitespace tolerance in decoding - surrounding spaces around delimiters and values",
|
|
5
|
+
"tests": [
|
|
6
|
+
{
|
|
7
|
+
"name": "tolerates spaces around commas in inline arrays",
|
|
8
|
+
"input": "tags[3]: a , b , c",
|
|
9
|
+
"expected": {
|
|
10
|
+
"tags": ["a", "b", "c"]
|
|
11
|
+
},
|
|
12
|
+
"specSection": "12",
|
|
13
|
+
"note": "Surrounding whitespace SHOULD be tolerated; tokens are trimmed"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "tolerates spaces around pipes in inline arrays",
|
|
17
|
+
"input": "tags[3|]: a | b | c",
|
|
18
|
+
"expected": {
|
|
19
|
+
"tags": ["a", "b", "c"]
|
|
20
|
+
},
|
|
21
|
+
"specSection": "12"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "tolerates spaces around tabs in inline arrays",
|
|
25
|
+
"input": "tags[3\t]: a \t b \t c",
|
|
26
|
+
"expected": {
|
|
27
|
+
"tags": ["a", "b", "c"]
|
|
28
|
+
},
|
|
29
|
+
"specSection": "12"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "tolerates leading and trailing spaces in tabular row values",
|
|
33
|
+
"input": "items[2]{id,name}:\n 1 , Alice \n 2 , Bob ",
|
|
34
|
+
"expected": {
|
|
35
|
+
"items": [
|
|
36
|
+
{ "id": 1, "name": "Alice" },
|
|
37
|
+
{ "id": 2, "name": "Bob" }
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"specSection": "12",
|
|
41
|
+
"note": "Values in tabular rows are trimmed"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "tolerates spaces around delimiters with quoted values",
|
|
45
|
+
"input": "items[3]: \"a\" , \"b\" , \"c\"",
|
|
46
|
+
"expected": {
|
|
47
|
+
"items": ["a", "b", "c"]
|
|
48
|
+
},
|
|
49
|
+
"specSection": "12"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "empty tokens decode to empty string",
|
|
53
|
+
"input": "items[3]: a,,c",
|
|
54
|
+
"expected": {
|
|
55
|
+
"items": ["a", "", "c"]
|
|
56
|
+
},
|
|
57
|
+
"specSection": "12",
|
|
58
|
+
"note": "Empty token (nothing between delimiters) decodes to empty string"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|