-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson_data_test.go
More file actions
476 lines (457 loc) · 9.76 KB
/
json_data_test.go
File metadata and controls
476 lines (457 loc) · 9.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
package hapijson
var jsonInvalidTestSet = []string{
// corrupted json
// test string
`string value`,
`"string value`,
`string value"`,
// unicode and hex
`"\uabaz"`,
`"\uab"`,
`"\ua"`,
`"\u"`,
`"\x.3"`,
`"\x1"`,
`"\"`,
// test numbers
`e32432`,
`01.234`,
`0e.32432`,
`0.324.32`,
`1234e.56789`,
`+123456.e-789`,
`-123456.-e789`,
`-123456.+E789`,
`-123456.789e`,
`-123456.e7e89`,
// test boolean and null
`tru`,
" truE",
" true,",
`fal`,
`falSe `,
` true 1`,
`nul`,
` nulL `,
` nu\lL `,
// test object and array
`[`,
`[[]`,
`{`,
`{{}`,
`[{]}`,
`[{"num":1234]}`,
`[{},{},3k]`,
`{"k":"val"`,
`43:"val"}`,
`{43:"val"}`,
`{:"val"}`,
`{key:val}`,
`{"key:val}`,
`{"key"val}`,
`{"key" val}`,
`{"key"\: "val"}`,
`{"key"::val}`,
`{"key":val}`,
`{"key":"val}`,
`{"key":"val",}`,
`{"key":{"k2"}}`,
`{"key":"val",, "k2": 234}`,
`{"key":"val", "k2": 234, [}`,
`{"key":"val", "k2": 234 }{`,
`{}[]`,
`[{]`,
`["v1" "v2"]`,
`["v1":"v2",]`,
`[{},]`,
`[{"k": 1,}]`,
`[{},value]`,
`[{},"fd",, 34]`,
`[{},"fd", 34],`,
`[{\},"fd", 34],`,
`[{},"fd", 34]{}`,
}
var jsonValidTestSet = []string{
// string
`"string value"`,
`"string \"value\""`,
// unicode and hex
`"\u0032"`,
`"\ud83d\ude02"`,
`"\ud83d"`,
`"\x32"`,
`"\xe8"`,
// numbers
`1234`,
`.1234`,
`1234.`,
`0.1234`,
`0.e1234`,
`0.e-1234`,
`0.e+1234`,
`0.E-1234`,
`0.E+1234`,
`0.1e-234`,
`0.1E-234`,
`0.1e+234`,
`0.1E+234`,
// boolean and null
`false`,
`true`,
`null`,
// object
`{}`,
`{"key": "234"}`,
`{"key": 234}`,
`{"key": true}`,
`{"key": false}`,
`{"key": false, "key2": "val2", "key3": []}`,
// array
`[]`,
`[1, 2, 3,4]`,
`["1", "2", 3,4]`,
`["1", "2", 3,4, false, true, null, {}]`,
`["1", "2", 3,4, false, true, null, {"key": "val"}]`,
// whites test
`[ ]`, `{ "k" : "34", "a r r ay" : [ 43 , 4 , "1" , false , true ,
null ]}`,
` { } `,
`{ "232"
:
"val
enter"
,
"
the key":
[
"
so what?
"
,
2
]
}`,
}
var jsonFromGoogleTranslator = `
[
[
["一个", "a", null, null, 1],
[null, null, "Yīgè", "ā,ə"]
],
[
[
"冠词",
["一个", "一"],
[
["一个", ["a", "an"], null, 0.121313766],
["一", ["a"], null, 0.036998607]
],
"a",
13
]
],
"en",
null,
null,
[
[
"a",
null,
[
["一个", 1000, true, false],
["一种", 1000, true, false],
["A", 1000, true, false],
["一", 0, true, false]
],
[[0, 1]],
"a",
0,
0
]
],
0.0,
[],
[["en"], null, [0.0], ["en"]],
null,
null,
[
[
"名词",
[
[["angstrom", "angstrom unit"], ""],
[["amp", "ampere"], ""],
[["axerophthol"], ""],
[["adenine"], ""]
],
"a"
]
],
[
[
"冠词",
[
[
"used when referring to someone or something for the first time in a text or conversation.",
"m_en_us1219181.001",
"a man came out of the room"
],
[
"used to indicate membership of a class of people or things.",
"m_en_us1219181.006",
"She's a banker, married to a stockbroker, and they have a daughter about the same age as Amy."
],
[
"used when expressing rates or ratios; in, to, or for each; per.",
"m_en_us1219181.007",
"You can't drive over five miles an hour down any street in New York."
]
],
"a"
]
],
[
[
[
"Regarding academic medicine, it has become increasingly difficult for \u003cb\u003ea\u003c/b\u003e Freud or a Mendel to gain recognition without university affiliation or corporate sponsorship.",
null,
null,
null,
3,
"m_en_us1219181.005"
],
[
"Bob's conducting a three-year internet romance with \u003cb\u003ea\u003c/b\u003e girl he's never met.",
null,
null,
null,
3,
"m_en_us1219181.001"
],
[
"About \u003cb\u003ea\u003c/b\u003e mile further down the road, another dog ran out in front of the taxi.",
null,
null,
null,
3,
"m_en_us1219181.002"
],
[
"The latest letter was from \u003cb\u003ea\u003c/b\u003e Mrs Singh, who complained about two radio stations.",
null,
null,
null,
3,
"m_en_us1219181.004"
],
[
"Called \u003cb\u003ea\u003c/b\u003e Judas by his countrymen, he received an elbow from another player, and left the pitch injured.",
null,
null,
null,
3,
"m_en_us1219181.005"
],
[
"Lilly is \u003cb\u003ea\u003c/b\u003e Siamese cat who survived a two-week cross-country move while stuck in a drawer.",
null,
null,
null,
3,
"m_en_us1219181.006"
],
[
"Does anyone know \u003cb\u003ea\u003c/b\u003e Mr Daeller?",
null,
null,
null,
3,
"m_en_us1219181.004"
],
[
"She was born in about 1670, the daughter of \u003cb\u003ea\u003c/b\u003e Mr Freeman of Holbeach in Lincolnshire.",
null,
null,
null,
3,
"m_en_us1219181.004"
],
[
"Children need \u003cb\u003ea\u003c/b\u003e place for their computer equipment, and parents need closet space for their clothing.",
null,
null,
null,
3,
"m_en_us1219181.001"
],
[
"typing 60 words \u003cb\u003ea\u003c/b\u003e minute",
null,
null,
null,
3,
"m_en_gb0000030.007"
],
[
"My mom's \u003cb\u003ea\u003c/b\u003e pharmacist and my dad's a realtor.",
null,
null,
null,
3,
"m_en_us1219181.006"
],
[
"The film looks fantastic: there is not \u003cb\u003ea\u003c/b\u003e spot, or a scratch, or a visual defect to be seen.",
null,
null,
null,
3,
"m_en_us1219181.003"
],
[
"We had to write \u003cb\u003ea\u003c/b\u003e story about a natural disaster for creative writing.",
null,
null,
null,
3,
"m_en_us1219181.001"
],
[
"On September 29 a letter arrived at our address for \u003cb\u003ea\u003c/b\u003e Ms L Doherty.",
null,
null,
null,
3,
"m_en_us1219181.004"
],
[
"I had to own up to the fact that I'd never read \u003cb\u003ea\u003c/b\u003e word by Crofts.",
null,
null,
null,
3,
"m_en_us1219181.003"
],
[
"I type 15 words \u003cb\u003ea\u003c/b\u003e minute with a lot of mistakes.",
null,
null,
null,
3,
"m_en_us1219181.007"
],
[
"I look at these miserable people, and wouldn't trade my life with theirs for \u003cb\u003ea\u003c/b\u003e million dollars.",
null,
null,
null,
3,
"m_en_us1219181.002"
],
[
"I stopped to pick up \u003cb\u003ea\u003c/b\u003e gallon of milk on my way home from work.",
null,
null,
null,
3,
"m_en_us1219181.002"
],
[
"Incensed at the fiasco, I went back to the website to try and find a telephone number to call - not \u003cb\u003ea\u003c/b\u003e thing!",
null,
null,
null,
3,
"m_en_us1219181.003"
],
[
"Most refugees say they never saw \u003cb\u003ea\u003c/b\u003e drop of food aid - despite almost one million tonnes flooding into the country every year.",
null,
null,
null,
3,
"m_en_us1219181.003"
],
[
"Notice that every car seen in the show is \u003cb\u003ea\u003c/b\u003e Chevrolet, out of consideration for their sponsor.",
null,
null,
null,
3,
"m_en_us1219181.006"
],
[
"\u003cb\u003ea\u003c/b\u003e Mr Smith telephoned",
null,
null,
null,
3,
"m_en_gb0000030.004"
],
[
"In 1984 he was granted his fervent wish to acquire \u003cb\u003ea\u003c/b\u003e Picasso.",
null,
null,
null,
3,
"m_en_us1219181.006"
],
[
"I think there's not \u003cb\u003ea\u003c/b\u003e person born that doesn't have a gift to offer in some way.",
null,
null,
null,
3,
"m_en_us1219181.003"
],
[
"An internal report written by \u003cb\u003ea\u003c/b\u003e manager at the nuclear waste reprocessing plant was leaked this week.",
null,
null,
null,
3,
"m_en_us1219181.001"
],
[
"Jack crouched down and hid behind \u003cb\u003ea\u003c/b\u003e tree trunk.",
null,
null,
null,
3,
"m_en_us1219181.001"
],
[
"\u003cb\u003ea\u003c/b\u003e Mr. Smith telephoned",
null,
null,
null,
3,
"m_en_us1219181.004"
],
[
"\u003cb\u003ea\u003c/b\u003e ringing of bells",
null,
null,
null,
3,
"neid_11"
],
[
"The truckers are angry at the rise in diesel prices, which currently average 81.3p \u003cb\u003ea\u003c/b\u003e litre.",
null,
null,
null,
3,
"m_en_us1219181.007"
],
[
"15 euro \u003cb\u003ea\u003c/b\u003e metre",
null,
null,
null,
3,
"neid_7"
]
]
]
]
`