@toon-format/spec 1.3.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 +42 -0
- package/CONTRIBUTING.md +259 -0
- package/LICENSE +21 -0
- package/README.md +111 -0
- package/SPEC.md +1089 -0
- package/VERSIONING.md +150 -0
- package/package.json +42 -0
- package/tests/README.md +218 -0
- package/tests/fixtures/decode/arrays-nested.json +156 -0
- package/tests/fixtures/decode/arrays-primitive.json +87 -0
- package/tests/fixtures/decode/arrays-tabular.json +40 -0
- package/tests/fixtures/decode/blank-lines.json +153 -0
- package/tests/fixtures/decode/delimiters.json +237 -0
- package/tests/fixtures/decode/indentation-errors.json +197 -0
- package/tests/fixtures/decode/objects.json +238 -0
- package/tests/fixtures/decode/primitives.json +189 -0
- package/tests/fixtures/decode/validation-errors.json +63 -0
- package/tests/fixtures/encode/arrays-nested.json +99 -0
- package/tests/fixtures/encode/arrays-objects.json +138 -0
- package/tests/fixtures/encode/arrays-primitive.json +87 -0
- package/tests/fixtures/encode/arrays-tabular.json +62 -0
- package/tests/fixtures/encode/delimiters.json +253 -0
- package/tests/fixtures/encode/normalization.json +107 -0
- package/tests/fixtures/encode/objects.json +220 -0
- package/tests/fixtures/encode/options.json +88 -0
- package/tests/fixtures/encode/primitives.json +226 -0
- package/tests/fixtures/encode/whitespace.json +29 -0
- package/tests/fixtures.schema.json +106 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.3",
|
|
3
|
+
"category": "decode",
|
|
4
|
+
"description": "Object decoding - simple objects, nested objects, key parsing, quoted values",
|
|
5
|
+
"tests": [
|
|
6
|
+
{
|
|
7
|
+
"name": "parses objects with primitive values",
|
|
8
|
+
"input": "id: 123\nname: Ada\nactive: true",
|
|
9
|
+
"expected": {
|
|
10
|
+
"id": 123,
|
|
11
|
+
"name": "Ada",
|
|
12
|
+
"active": true
|
|
13
|
+
},
|
|
14
|
+
"specSection": "6"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "parses null values in objects",
|
|
18
|
+
"input": "id: 123\nvalue: null",
|
|
19
|
+
"expected": {
|
|
20
|
+
"id": 123,
|
|
21
|
+
"value": null
|
|
22
|
+
},
|
|
23
|
+
"specSection": "6"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "parses empty nested object header",
|
|
27
|
+
"input": "user:",
|
|
28
|
+
"expected": {
|
|
29
|
+
"user": {}
|
|
30
|
+
},
|
|
31
|
+
"specSection": "6"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "parses quoted object value with colon",
|
|
35
|
+
"input": "note: \"a:b\"",
|
|
36
|
+
"expected": {
|
|
37
|
+
"note": "a:b"
|
|
38
|
+
},
|
|
39
|
+
"specSection": "6"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "parses quoted object value with comma",
|
|
43
|
+
"input": "note: \"a,b\"",
|
|
44
|
+
"expected": {
|
|
45
|
+
"note": "a,b"
|
|
46
|
+
},
|
|
47
|
+
"specSection": "6"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "parses quoted object value with newline escape",
|
|
51
|
+
"input": "text: \"line1\\nline2\"",
|
|
52
|
+
"expected": {
|
|
53
|
+
"text": "line1\nline2"
|
|
54
|
+
},
|
|
55
|
+
"specSection": "6"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "parses quoted object value with escaped quotes",
|
|
59
|
+
"input": "text: \"say \\\"hello\\\"\"",
|
|
60
|
+
"expected": {
|
|
61
|
+
"text": "say \"hello\""
|
|
62
|
+
},
|
|
63
|
+
"specSection": "6"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "parses quoted object value with leading/trailing spaces",
|
|
67
|
+
"input": "text: \" padded \"",
|
|
68
|
+
"expected": {
|
|
69
|
+
"text": " padded "
|
|
70
|
+
},
|
|
71
|
+
"specSection": "6"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "parses quoted object value with only spaces",
|
|
75
|
+
"input": "text: \" \"",
|
|
76
|
+
"expected": {
|
|
77
|
+
"text": " "
|
|
78
|
+
},
|
|
79
|
+
"specSection": "6"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"name": "parses quoted string value that looks like true",
|
|
83
|
+
"input": "v: \"true\"",
|
|
84
|
+
"expected": {
|
|
85
|
+
"v": "true"
|
|
86
|
+
},
|
|
87
|
+
"specSection": "6"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "parses quoted string value that looks like integer",
|
|
91
|
+
"input": "v: \"42\"",
|
|
92
|
+
"expected": {
|
|
93
|
+
"v": "42"
|
|
94
|
+
},
|
|
95
|
+
"specSection": "6"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "parses quoted string value that looks like negative decimal",
|
|
99
|
+
"input": "v: \"-7.5\"",
|
|
100
|
+
"expected": {
|
|
101
|
+
"v": "-7.5"
|
|
102
|
+
},
|
|
103
|
+
"specSection": "6"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"name": "parses quoted key with colon",
|
|
107
|
+
"input": "\"order:id\": 7",
|
|
108
|
+
"expected": {
|
|
109
|
+
"order:id": 7
|
|
110
|
+
},
|
|
111
|
+
"specSection": "6"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "parses quoted key with brackets",
|
|
115
|
+
"input": "\"[index]\": 5",
|
|
116
|
+
"expected": {
|
|
117
|
+
"[index]": 5
|
|
118
|
+
},
|
|
119
|
+
"specSection": "6"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "parses quoted key with braces",
|
|
123
|
+
"input": "\"{key}\": 5",
|
|
124
|
+
"expected": {
|
|
125
|
+
"{key}": 5
|
|
126
|
+
},
|
|
127
|
+
"specSection": "6"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"name": "parses quoted key with comma",
|
|
131
|
+
"input": "\"a,b\": 1",
|
|
132
|
+
"expected": {
|
|
133
|
+
"a,b": 1
|
|
134
|
+
},
|
|
135
|
+
"specSection": "6"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "parses quoted key with spaces",
|
|
139
|
+
"input": "\"full name\": Ada",
|
|
140
|
+
"expected": {
|
|
141
|
+
"full name": "Ada"
|
|
142
|
+
},
|
|
143
|
+
"specSection": "6"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "parses quoted key with leading hyphen",
|
|
147
|
+
"input": "\"-lead\": 1",
|
|
148
|
+
"expected": {
|
|
149
|
+
"-lead": 1
|
|
150
|
+
},
|
|
151
|
+
"specSection": "6"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"name": "parses quoted key with leading and trailing spaces",
|
|
155
|
+
"input": "\" a \": 1",
|
|
156
|
+
"expected": {
|
|
157
|
+
" a ": 1
|
|
158
|
+
},
|
|
159
|
+
"specSection": "6"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "parses quoted numeric key",
|
|
163
|
+
"input": "\"123\": x",
|
|
164
|
+
"expected": {
|
|
165
|
+
"123": "x"
|
|
166
|
+
},
|
|
167
|
+
"specSection": "6"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"name": "parses quoted empty string key",
|
|
171
|
+
"input": "\"\": 1",
|
|
172
|
+
"expected": {
|
|
173
|
+
"": 1
|
|
174
|
+
},
|
|
175
|
+
"specSection": "6"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"name": "parses dotted keys as identifiers",
|
|
179
|
+
"input": "user.name: Ada",
|
|
180
|
+
"expected": {
|
|
181
|
+
"user.name": "Ada"
|
|
182
|
+
},
|
|
183
|
+
"specSection": "6"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"name": "parses underscore-prefixed keys",
|
|
187
|
+
"input": "_private: 1",
|
|
188
|
+
"expected": {
|
|
189
|
+
"_private": 1
|
|
190
|
+
},
|
|
191
|
+
"specSection": "6"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"name": "parses underscore-containing keys",
|
|
195
|
+
"input": "user_name: 1",
|
|
196
|
+
"expected": {
|
|
197
|
+
"user_name": 1
|
|
198
|
+
},
|
|
199
|
+
"specSection": "6"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"name": "unescapes newline in key",
|
|
203
|
+
"input": "\"line\\nbreak\": 1",
|
|
204
|
+
"expected": {
|
|
205
|
+
"line\nbreak": 1
|
|
206
|
+
},
|
|
207
|
+
"specSection": "6"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"name": "unescapes tab in key",
|
|
211
|
+
"input": "\"tab\\there\": 2",
|
|
212
|
+
"expected": {
|
|
213
|
+
"tab\there": 2
|
|
214
|
+
},
|
|
215
|
+
"specSection": "6"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"name": "unescapes quotes in key",
|
|
219
|
+
"input": "\"he said \\\"hi\\\"\": 1",
|
|
220
|
+
"expected": {
|
|
221
|
+
"he said \"hi\"": 1
|
|
222
|
+
},
|
|
223
|
+
"specSection": "6"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"name": "parses deeply nested objects with indentation",
|
|
227
|
+
"input": "a:\n b:\n c: deep",
|
|
228
|
+
"expected": {
|
|
229
|
+
"a": {
|
|
230
|
+
"b": {
|
|
231
|
+
"c": "deep"
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
"specSection": "6"
|
|
236
|
+
}
|
|
237
|
+
]
|
|
238
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.3",
|
|
3
|
+
"category": "decode",
|
|
4
|
+
"description": "Primitive value decoding - strings, numbers, booleans, null, unescaping",
|
|
5
|
+
"tests": [
|
|
6
|
+
{
|
|
7
|
+
"name": "decodes safe unquoted string",
|
|
8
|
+
"input": "hello",
|
|
9
|
+
"expected": "hello",
|
|
10
|
+
"specSection": "5"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "decodes unquoted string with underscore and numbers",
|
|
14
|
+
"input": "Ada_99",
|
|
15
|
+
"expected": "Ada_99",
|
|
16
|
+
"specSection": "5"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "decodes empty quoted string",
|
|
20
|
+
"input": "\"\"",
|
|
21
|
+
"expected": "",
|
|
22
|
+
"specSection": "5"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "decodes quoted string with newline escape",
|
|
26
|
+
"input": "\"line1\\nline2\"",
|
|
27
|
+
"expected": "line1\nline2",
|
|
28
|
+
"specSection": "5"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "decodes quoted string with tab escape",
|
|
32
|
+
"input": "\"tab\\there\"",
|
|
33
|
+
"expected": "tab\there",
|
|
34
|
+
"specSection": "5"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "decodes quoted string with carriage return escape",
|
|
38
|
+
"input": "\"return\\rcarriage\"",
|
|
39
|
+
"expected": "return\rcarriage",
|
|
40
|
+
"specSection": "5"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "decodes quoted string with backslash escape",
|
|
44
|
+
"input": "\"C:\\\\Users\\\\path\"",
|
|
45
|
+
"expected": "C:\\Users\\path",
|
|
46
|
+
"specSection": "5"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "decodes quoted string with escaped quotes",
|
|
50
|
+
"input": "\"say \\\"hello\\\"\"",
|
|
51
|
+
"expected": "say \"hello\"",
|
|
52
|
+
"specSection": "5"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "decodes Unicode string",
|
|
56
|
+
"input": "café",
|
|
57
|
+
"expected": "café",
|
|
58
|
+
"specSection": "5"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "decodes Chinese characters",
|
|
62
|
+
"input": "你好",
|
|
63
|
+
"expected": "你好",
|
|
64
|
+
"specSection": "5"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "decodes emoji",
|
|
68
|
+
"input": "🚀",
|
|
69
|
+
"expected": "🚀",
|
|
70
|
+
"specSection": "5"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"name": "decodes string with emoji and spaces",
|
|
74
|
+
"input": "hello 👋 world",
|
|
75
|
+
"expected": "hello 👋 world",
|
|
76
|
+
"specSection": "5"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "decodes positive integer",
|
|
80
|
+
"input": "42",
|
|
81
|
+
"expected": 42,
|
|
82
|
+
"specSection": "5"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "decodes decimal number",
|
|
86
|
+
"input": "3.14",
|
|
87
|
+
"expected": 3.14,
|
|
88
|
+
"specSection": "5"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "decodes negative integer",
|
|
92
|
+
"input": "-7",
|
|
93
|
+
"expected": -7,
|
|
94
|
+
"specSection": "5"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "decodes true",
|
|
98
|
+
"input": "true",
|
|
99
|
+
"expected": true,
|
|
100
|
+
"specSection": "5"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "decodes false",
|
|
104
|
+
"input": "false",
|
|
105
|
+
"expected": false,
|
|
106
|
+
"specSection": "5"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "decodes null",
|
|
110
|
+
"input": "null",
|
|
111
|
+
"expected": null,
|
|
112
|
+
"specSection": "5"
|
|
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"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "respects ambiguity quoting for true",
|
|
147
|
+
"input": "\"true\"",
|
|
148
|
+
"expected": "true",
|
|
149
|
+
"specSection": "5",
|
|
150
|
+
"note": "Quoted primitive remains string"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"name": "respects ambiguity quoting for false",
|
|
154
|
+
"input": "\"false\"",
|
|
155
|
+
"expected": "false",
|
|
156
|
+
"specSection": "5"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"name": "respects ambiguity quoting for null",
|
|
160
|
+
"input": "\"null\"",
|
|
161
|
+
"expected": "null",
|
|
162
|
+
"specSection": "5"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"name": "respects ambiguity quoting for integer",
|
|
166
|
+
"input": "\"42\"",
|
|
167
|
+
"expected": "42",
|
|
168
|
+
"specSection": "5"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "respects ambiguity quoting for negative decimal",
|
|
172
|
+
"input": "\"-3.14\"",
|
|
173
|
+
"expected": "-3.14",
|
|
174
|
+
"specSection": "5"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"name": "respects ambiguity quoting for scientific notation",
|
|
178
|
+
"input": "\"1e-6\"",
|
|
179
|
+
"expected": "1e-6",
|
|
180
|
+
"specSection": "5"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"name": "respects ambiguity quoting for leading-zero",
|
|
184
|
+
"input": "\"05\"",
|
|
185
|
+
"expected": "05",
|
|
186
|
+
"specSection": "5"
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.3",
|
|
3
|
+
"category": "decode",
|
|
4
|
+
"description": "Validation errors - length mismatches, invalid escapes, syntax errors, delimiter mismatches",
|
|
5
|
+
"tests": [
|
|
6
|
+
{
|
|
7
|
+
"name": "throws on array length mismatch (inline primitives - too many)",
|
|
8
|
+
"input": "tags[2]: a,b,c",
|
|
9
|
+
"expected": null,
|
|
10
|
+
"shouldError": true,
|
|
11
|
+
"specSection": "9"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "throws on array length mismatch (list format - too many)",
|
|
15
|
+
"input": "items[1]:\n - 1\n - 2",
|
|
16
|
+
"expected": null,
|
|
17
|
+
"shouldError": true,
|
|
18
|
+
"specSection": "9"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "throws when tabular row value count does not match header field count",
|
|
22
|
+
"input": "items[2]{id,name}:\n 1,Ada\n 2",
|
|
23
|
+
"expected": null,
|
|
24
|
+
"shouldError": true,
|
|
25
|
+
"specSection": "9"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "throws when tabular row count does not match header length",
|
|
29
|
+
"input": "[1]{id}:\n 1\n 2",
|
|
30
|
+
"expected": null,
|
|
31
|
+
"shouldError": true,
|
|
32
|
+
"specSection": "9"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "throws on invalid escape sequence",
|
|
36
|
+
"input": "\"a\\x\"",
|
|
37
|
+
"expected": null,
|
|
38
|
+
"shouldError": true,
|
|
39
|
+
"specSection": "9"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "throws on unterminated string",
|
|
43
|
+
"input": "\"unterminated",
|
|
44
|
+
"expected": null,
|
|
45
|
+
"shouldError": true,
|
|
46
|
+
"specSection": "9"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "throws on missing colon in key-value context",
|
|
50
|
+
"input": "a:\n user",
|
|
51
|
+
"expected": null,
|
|
52
|
+
"shouldError": true,
|
|
53
|
+
"specSection": "9"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "throws on delimiter mismatch (header declares tab, row uses comma)",
|
|
57
|
+
"input": "items[2\t]{a\tb}:\n 1,2\n 3,4",
|
|
58
|
+
"expected": null,
|
|
59
|
+
"shouldError": true,
|
|
60
|
+
"specSection": "9"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.3",
|
|
3
|
+
"category": "encode",
|
|
4
|
+
"description": "Nested and mixed array encoding - arrays of arrays, mixed type arrays, root arrays",
|
|
5
|
+
"tests": [
|
|
6
|
+
{
|
|
7
|
+
"name": "encodes nested arrays of primitives",
|
|
8
|
+
"input": {
|
|
9
|
+
"pairs": [["a", "b"], ["c", "d"]]
|
|
10
|
+
},
|
|
11
|
+
"expected": "pairs[2]:\n - [2]: a,b\n - [2]: c,d",
|
|
12
|
+
"specSection": "7.3"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "quotes strings containing delimiters in nested arrays",
|
|
16
|
+
"input": {
|
|
17
|
+
"pairs": [["a", "b"], ["c,d", "e:f", "true"]]
|
|
18
|
+
},
|
|
19
|
+
"expected": "pairs[2]:\n - [2]: a,b\n - [3]: \"c,d\",\"e:f\",\"true\"",
|
|
20
|
+
"specSection": "7.3"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "handles empty inner arrays",
|
|
24
|
+
"input": {
|
|
25
|
+
"pairs": [[], []]
|
|
26
|
+
},
|
|
27
|
+
"expected": "pairs[2]:\n - [0]:\n - [0]:",
|
|
28
|
+
"specSection": "7.3"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "handles mixed-length inner arrays",
|
|
32
|
+
"input": {
|
|
33
|
+
"pairs": [[1], [2, 3]]
|
|
34
|
+
},
|
|
35
|
+
"expected": "pairs[2]:\n - [1]: 1\n - [2]: 2,3",
|
|
36
|
+
"specSection": "7.3"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "encodes root-level primitive array",
|
|
40
|
+
"input": ["x", "y", "true", true, 10],
|
|
41
|
+
"expected": "[5]: x,y,\"true\",true,10",
|
|
42
|
+
"specSection": "7"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "encodes root-level array of uniform objects in tabular format",
|
|
46
|
+
"input": [{ "id": 1 }, { "id": 2 }],
|
|
47
|
+
"expected": "[2]{id}:\n 1\n 2",
|
|
48
|
+
"specSection": "7.2"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "encodes root-level array of non-uniform objects in list format",
|
|
52
|
+
"input": [{ "id": 1 }, { "id": 2, "name": "Ada" }],
|
|
53
|
+
"expected": "[2]:\n - id: 1\n - id: 2\n name: Ada",
|
|
54
|
+
"specSection": "7"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "encodes empty root-level array",
|
|
58
|
+
"input": [],
|
|
59
|
+
"expected": "[0]:",
|
|
60
|
+
"specSection": "7"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "encodes root-level arrays of arrays",
|
|
64
|
+
"input": [[1, 2], []],
|
|
65
|
+
"expected": "[2]:\n - [2]: 1,2\n - [0]:",
|
|
66
|
+
"specSection": "7.3"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"name": "encodes complex nested structure",
|
|
70
|
+
"input": {
|
|
71
|
+
"user": {
|
|
72
|
+
"id": 123,
|
|
73
|
+
"name": "Ada",
|
|
74
|
+
"tags": ["reading", "gaming"],
|
|
75
|
+
"active": true,
|
|
76
|
+
"prefs": []
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"expected": "user:\n id: 123\n name: Ada\n tags[2]: reading,gaming\n active: true\n prefs[0]:",
|
|
80
|
+
"specSection": "6"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "uses list format for arrays mixing primitives and objects",
|
|
84
|
+
"input": {
|
|
85
|
+
"items": [1, { "a": 1 }, "text"]
|
|
86
|
+
},
|
|
87
|
+
"expected": "items[3]:\n - 1\n - a: 1\n - text",
|
|
88
|
+
"specSection": "7.3"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "uses list format for arrays mixing objects and arrays",
|
|
92
|
+
"input": {
|
|
93
|
+
"items": [{ "a": 1 }, [1, 2]]
|
|
94
|
+
},
|
|
95
|
+
"expected": "items[2]:\n - a: 1\n - [2]: 1,2",
|
|
96
|
+
"specSection": "7.3"
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|