json-as 1.0.0-alpha.2 → 1.0.0-alpha.4

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.
Files changed (46) hide show
  1. package/.prettierignore +6 -0
  2. package/.prettierrc.json +0 -1
  3. package/CHANGELOG +23 -1
  4. package/README.md +33 -21
  5. package/as-test.config.json +1 -1
  6. package/asconfig.json +1 -29
  7. package/assembly/__tests__/array.spec.ts +67 -0
  8. package/assembly/__tests__/bool.spec.ts +4 -12
  9. package/assembly/__tests__/box.spec.ts +37 -0
  10. package/assembly/__tests__/date.spec.ts +38 -0
  11. package/assembly/__tests__/float.spec.ts +11 -21
  12. package/assembly/__tests__/integer.spec.ts +7 -9
  13. package/assembly/__tests__/null.spec.ts +12 -0
  14. package/assembly/__tests__/obj.spec.ts +137 -3
  15. package/assembly/__tests__/simd/string.spec.ts +21 -21
  16. package/assembly/__tests__/string.spec.ts +6 -4
  17. package/assembly/__tests__/test.spec.ts +120 -191
  18. package/assembly/deserialize/simple/bool.ts +5 -8
  19. package/assembly/deserialize/simple/date.ts +2 -2
  20. package/assembly/deserialize/simple/map.ts +1 -1
  21. package/assembly/deserialize/simple/object.ts +3 -1
  22. package/assembly/deserialize/simple/string.ts +4 -3
  23. package/assembly/globals/tables.ts +74 -416
  24. package/assembly/index.ts +48 -25
  25. package/assembly/serialize/simd/string.ts +11 -11
  26. package/assembly/serialize/simple/array.ts +5 -4
  27. package/assembly/serialize/simple/bool.ts +2 -2
  28. package/assembly/serialize/simple/date.ts +1 -1
  29. package/assembly/serialize/simple/integer.ts +6 -1
  30. package/assembly/serialize/simple/map.ts +6 -6
  31. package/assembly/serialize/simple/string.ts +3 -3
  32. package/assembly/test.ts +30 -15
  33. package/assembly/util/bytes.ts +1 -1
  34. package/assembly/util/snp.ts +2 -2
  35. package/modules/as-bs/assembly/index.ts +73 -92
  36. package/modules/test/assembly/index.ts +22 -0
  37. package/package.json +6 -10
  38. package/run-tests.sh +15 -0
  39. package/transform/lib/builder.js +1340 -1262
  40. package/transform/lib/index.js +582 -512
  41. package/transform/lib/index.js.map +1 -1
  42. package/transform/lib/linker.js +12 -10
  43. package/transform/lib/types.js +19 -19
  44. package/transform/lib/util.js +34 -34
  45. package/transform/lib/visitor.js +529 -526
  46. package/transform/src/index.ts +22 -16
@@ -1,417 +1,75 @@
1
1
  export const SERIALIZE_ESCAPE_TABLE = memory.data<u16>([
2
- 48,
3
- 48,
4
- 48,
5
- 49,
6
- 48,
7
- 50,
8
- 48,
9
- 51, // Pair 0-3
10
- 48,
11
- 52,
12
- 48,
13
- 53,
14
- 48,
15
- 54,
16
- 48,
17
- 55, // Pair 4-7
18
-
19
- 92,
20
- 98,
21
- 92,
22
- 116,
23
- 92,
24
- 110,
25
- 48,
26
- 98, // Pair 8-11
27
- 92,
28
- 102,
29
- 92,
30
- 114,
31
- 48,
32
- 101,
33
- 48,
34
- 102, // Pair 12-15
35
-
36
- 49,
37
- 48,
38
- 49,
39
- 49,
40
- 49,
41
- 50,
42
- 49,
43
- 51, // Pair 16-19
44
- 49,
45
- 52,
46
- 49,
47
- 53,
48
- 49,
49
- 54,
50
- 49,
51
- 55, // Pair 20-23
52
-
53
- 49,
54
- 56,
55
- 49,
56
- 57,
57
- 49,
58
- 97,
59
- 49,
60
- 98, // Pair 24-27
61
- 49,
62
- 99,
63
- 49,
64
- 100,
65
- 49,
66
- 101,
67
- 49,
68
- 102, // Pair 28-31
69
-
70
- 0,
71
- 0,
72
- 0,
73
- 0,
74
- 92,
75
- 34,
76
- 0,
77
- 0, // Pair 32-35
78
- 0,
79
- 0,
80
- 0,
81
- 0,
82
- 0,
83
- 0,
84
- 0,
85
- 0, // Pair 36-39
86
-
87
- 0,
88
- 0,
89
- 0,
90
- 0,
91
- 0,
92
- 0,
93
- 0,
94
- 0, // Pair 40-43
95
- 0,
96
- 0,
97
- 0,
98
- 0,
99
- 0,
100
- 0,
101
- 0,
102
- 0, // Pair 44-47
103
-
104
- 0,
105
- 0,
106
- 0,
107
- 0,
108
- 0,
109
- 0,
110
- 0,
111
- 0, // Pair 48-51
112
- 0,
113
- 0,
114
- 0,
115
- 0,
116
- 0,
117
- 0,
118
- 0,
119
- 0, // Pair 52-55
120
-
121
- 0,
122
- 0,
123
- 0,
124
- 0,
125
- 0,
126
- 0,
127
- 0,
128
- 0, // Pair 56-59
129
- 0,
130
- 0,
131
- 0,
132
- 0,
133
- 0,
134
- 0,
135
- 0,
136
- 0, // Pair 60-63
137
-
138
- 0,
139
- 0,
140
- 0,
141
- 0,
142
- 0,
143
- 0,
144
- 0,
145
- 0, // Pair 64-67
146
- 0,
147
- 0,
148
- 0,
149
- 0,
150
- 0,
151
- 0,
152
- 0,
153
- 0, // Pair 68-71
154
-
155
- 0,
156
- 0,
157
- 0,
158
- 0,
159
- 0,
160
- 0,
161
- 0,
162
- 0, // Pair 72-75
163
- 0,
164
- 0,
165
- 0,
166
- 0,
167
- 0,
168
- 0,
169
- 0,
170
- 0, // Pair 76-79
171
-
172
- 0,
173
- 0,
174
- 0,
175
- 0,
176
- 0,
177
- 0,
178
- 0,
179
- 0, // Pair 80-83
180
- 0,
181
- 0,
182
- 0,
183
- 0,
184
- 0,
185
- 0,
186
- 0,
187
- 0, // Pair 84-87
188
-
189
- 0,
190
- 0,
191
- 0,
192
- 0,
193
- 0,
194
- 0,
195
- 0,
196
- 0, // Pair 88-91
197
- 92,
198
- 92, // Pair 92-93
199
- ]);
200
-
201
- export const DESERIALIZE_ESCAPE_TABLE = memory.data<u8>([
202
- 0,
203
- 0,
204
- 0,
205
- 0,
206
- 0,
207
- 0,
208
- 0,
209
- 0, // 0-7
210
- 0,
211
- 0,
212
- 0,
213
- 0,
214
- 0,
215
- 0,
216
- 0,
217
- 0, // 8-15
218
- 0,
219
- 0,
220
- 0,
221
- 0,
222
- 0,
223
- 0,
224
- 0,
225
- 0, // 16-23
226
- 0,
227
- 0,
228
- 0,
229
- 0,
230
- 0,
231
- 0,
232
- 0,
233
- 0, // 24-31
234
- 0,
235
- 0,
236
- 34,
237
- 0,
238
- 0,
239
- 0,
240
- 0,
241
- 0, // 32-39
242
- 0,
243
- 0,
244
- 0,
245
- 0,
246
- 0,
247
- 0,
248
- 0,
249
- 0, // 40-47
250
- 0,
251
- 0,
252
- 0,
253
- 0,
254
- 0,
255
- 0,
256
- 0,
257
- 0, // 48-55
258
- 0,
259
- 0,
260
- 0,
261
- 0,
262
- 0,
263
- 0,
264
- 0,
265
- 0, // 56-63
266
- 0,
267
- 0,
268
- 0,
269
- 0,
270
- 0,
271
- 0,
272
- 0,
273
- 0, // 64-71
274
- 0,
275
- 0,
276
- 0,
277
- 0,
278
- 0,
279
- 0,
280
- 0,
281
- 0, // 72-79
282
- 0,
283
- 0,
284
- 0,
285
- 0,
286
- 0,
287
- 0,
288
- 0,
289
- 0, // 80-87
290
- 0,
291
- 0,
292
- 0,
293
- 0,
294
- 92,
295
- 0,
296
- 0,
297
- 0, // 88-95
298
- 0,
299
- 0,
300
- 8,
301
- 0,
302
- 0,
303
- 0,
304
- 12,
305
- 0, // 96-103
306
- 0,
307
- 0,
308
- 0,
309
- 0,
310
- 0,
311
- 0,
312
- 10,
313
- 0, // 104-111
314
- 0,
315
- 0,
316
- 13,
317
- 0,
318
- 9,
319
- 117,
320
- 0,
321
- 0, // 112-119
322
- 0,
323
- 0,
324
- 0,
325
- 0,
326
- 0,
327
- 0,
328
- 0,
329
- 0, // 120-127
330
- 0,
331
- 0,
332
- 0,
333
- 0,
334
- 0,
335
- 0,
336
- 0,
337
- 0, // 128-135
338
- 0,
339
- 0,
340
- 0,
341
- 0,
342
- 0,
343
- 0,
344
- 0,
345
- 0, // 136-143
346
- 0,
347
- 0,
348
- 0,
349
- 0,
350
- 0,
351
- 0,
352
- 0,
353
- 0, // 144-151
354
- ]);
355
-
356
- export const ESCAPE_HEX_TABLE =
357
- memory.data<u8>([
358
- 0,
359
- 1,
360
- 2,
361
- 3,
362
- 4,
363
- 5,
364
- 6,
365
- 7, // 0-7
366
- 8,
367
- 9,
368
- 0,
369
- 0,
370
- 0,
371
- 0,
372
- 0,
373
- 0, // 8-15
374
- 0,
375
- 0,
376
- 0,
377
- 0,
378
- 0,
379
- 0,
380
- 0,
381
- 0, // 16-23
382
- 0,
383
- 0,
384
- 0,
385
- 0,
386
- 0,
387
- 0,
388
- 0,
389
- 0, // 24-31
390
- 0,
391
- 0,
392
- 0,
393
- 0,
394
- 0,
395
- 0,
396
- 0,
397
- 0, // 32-39
398
- 0,
399
- 0,
400
- 0,
401
- 0,
402
- 0,
403
- 0,
404
- 0,
405
- 0, // 40-47
406
- 0,
407
- 10,
408
- 11,
409
- 12,
410
- 13,
411
- 14,
412
- 15, // 48-54
413
- ]) - 48;
414
-
415
- export const POW_TEN_TABLE_32 = memory.data<u32>([1, 10, 1_000, 10_000, 100_000, 1_000_000, 10_000_000, 100_000_000, 1_000_000_000]);
416
-
417
- export const POW_TEN_TABLE_64 = memory.data<u64>([1, 10, 1_000, 10_000, 100_000, 1_000_000, 10_000_000, 100_000_000, 1_000_000_000, 10_000_000_000, 100_000_000_000, 1_000_000_000_000, 10_000_000_000_000, 100_000_000_000_000, 1_000_000_000_000_000, 10_000_000_000_000_000, 100_000_000_000_000_000, 1_000_000_000_000_000_000, 10_000_000_000_000_000_000]);
2
+ 48, 48, 48, 49, 48, 50, 48, 51, // Pair 0-3
3
+ 48, 52, 48, 53, 48, 54, 48, 55, // Pair 4-7
4
+
5
+ 92, 98, 92, 116, 92, 110, 48, 98, // Pair 8-11
6
+ 92, 102, 92, 114, 48, 101, 48, 102, // Pair 12-15
7
+
8
+ 49, 48, 49, 49, 49, 50, 49, 51, // Pair 16-19
9
+ 49, 52, 49, 53, 49, 54, 49, 55, // Pair 20-23
10
+
11
+ 49, 56, 49, 57, 49, 97, 49, 98, // Pair 24-27
12
+ 49, 99, 49, 100, 49, 101, 49, 102, // Pair 28-31
13
+
14
+ 0, 0, 0, 0, 92, 34, 0, 0, // Pair 32-35
15
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 36-39
16
+
17
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 40-43
18
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 44-47
19
+
20
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 48-51
21
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 52-55
22
+
23
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 56-59
24
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 60-63
25
+
26
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 64-67
27
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 68-71
28
+
29
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 72-75
30
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 76-79
31
+
32
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 80-83
33
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 84-87
34
+
35
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 88-91
36
+ 92, 92, // Pair 92-93
37
+ ]);
38
+
39
+ export const DESERIALIZE_ESCAPE_TABLE = memory.data<u8>([
40
+ 0, 0, 0, 0, 0, 0, 0, 0, // 0-7
41
+ 0, 0, 0, 0, 0, 0, 0, 0, // 8-15
42
+ 0, 0, 0, 0, 0, 0, 0, 0, // 16-23
43
+ 0, 0, 0, 0, 0, 0, 0, 0, // 24-31
44
+ 0, 0, 34, 0, 0, 0, 0, 0, // 32-39
45
+ 0, 0, 0, 0, 0, 0, 0, 0, // 40-47
46
+ 0, 0, 0, 0, 0, 0, 0, 0, // 48-55
47
+ 0, 0, 0, 0, 0, 0, 0, 0, // 56-63
48
+ 0, 0, 0, 0, 0, 0, 0, 0, // 64-71
49
+ 0, 0, 0, 0, 0, 0, 0, 0, // 72-79
50
+ 0, 0, 0, 0, 0, 0, 0, 0, // 80-87
51
+ 0, 0, 0, 0, 92, 0, 0, 0, // 88-95
52
+ 0, 0, 8, 0, 0, 0, 12, 0, // 96-103
53
+ 0, 0, 0, 0, 0, 0, 10, 0, // 104-111
54
+ 0, 0, 13, 0, 9, 117, 0, 0, // 112-119
55
+ 0, 0, 0, 0, 0, 0, 0, 0, // 120-127
56
+ 0, 0, 0, 0, 0, 0, 0, 0, // 128-135
57
+ 0, 0, 0, 0, 0, 0, 0, 0, // 136-143
58
+ 0, 0, 0, 0, 0, 0, 0, 0, // 144-151
59
+ ]);
60
+
61
+ export const ESCAPE_HEX_TABLE =
62
+ memory.data<u8>([
63
+ 0, 1, 2, 3, 4, 5, 6, 7, // 0-7
64
+ 8, 9, 0, 0, 0, 0, 0, 0, // 8-15
65
+ 0, 0, 0, 0, 0, 0, 0, 0, // 16-23
66
+ 0, 0, 0, 0, 0, 0, 0, 0, // 24-31
67
+ 0, 0, 0, 0, 0, 0, 0, 0, // 32-39
68
+ 0, 0, 0, 0, 0, 0, 0, 0, // 40-47
69
+ 0, 10, 11, 12, 13, 14, 15, // 48-54
70
+ ]) - 48;
71
+
72
+ export const POW_TEN_TABLE_32 = memory.data<u32>([1, 10, 1_000, 10_000, 100_000, 1_000_000, 10_000_000, 100_000_000, 1_000_000_000]);
73
+
74
+ export const POW_TEN_TABLE_64 = memory.data<u64>([1, 10, 1_000, 10_000, 100_000, 1_000_000, 10_000_000, 100_000_000, 1_000_000_000, 10_000_000_000, 100_000_000_000, 1_000_000_000_000, 10_000_000_000_000, 100_000_000_000_000, 1_000_000_000_000_000, 10_000_000_000_000_000, 100_000_000_000_000_000, 1_000_000_000_000_000_000, 10_000_000_000_000_000_000]);
75
+
package/assembly/index.ts CHANGED
@@ -36,6 +36,11 @@ export type Raw = string;
36
36
  * JSON Encoder/Decoder for AssemblyScript
37
37
  */
38
38
  export namespace JSON {
39
+ export namespace Memory {
40
+ export function shrink(): void {
41
+ bs.resize(64);
42
+ }
43
+ }
39
44
  /**
40
45
  * Serializes valid JSON data
41
46
  * ```js
@@ -93,23 +98,21 @@ export namespace JSON {
93
98
  return NULL_WORD;
94
99
  // @ts-ignore
95
100
  } else if (isString<nonnull<T>>()) {
96
- if (out) {
97
- out = changetype<string>(__renew(changetype<usize>(out), bytes(data) + 4));
98
- // const oldSize = bs.byteLength;
99
- const oldBuf = bs.buffer;
100
- const newSize = bytes(data) + 4;
101
- const newBuf = __new(newSize, idof<string>());
102
- bs.setBuffer(newBuf);
103
- serializeString(changetype<string>(data));
104
- bs.setBuffer(oldBuf);
105
- return changetype<string>(newBuf);
106
- }
101
+ // if (out) {
102
+ // out = changetype<string>(__renew(changetype<usize>(out), bytes(data) + 4));
103
+ // // const oldSize = bs.byteLength;
104
+ // const oldBuf = bs.buffer;
105
+ // const newSize = bytes(data) + 4;
106
+ // const newBuf = __new(newSize, idof<string>());
107
+ // bs.setBuffer(newBuf);
108
+ // serializeString(changetype<string>(data));
109
+ // bs.setBuffer(oldBuf);
110
+ // return changetype<string>(newBuf);
111
+ // }
107
112
  serializeString(changetype<string>(data));
108
113
  return bs.out<string>();
109
114
  // @ts-ignore: Supplied by transform
110
- } else if (isDefined(data.__SERIALIZE) && isDefined(data.__ALLOCATE)) {
111
- // @ts-ignore
112
- data.__ALLOCATE();
115
+ } else if (isDefined(data.__SERIALIZE)) {
113
116
  // @ts-ignore
114
117
  data.__SERIALIZE(changetype<usize>(data));
115
118
  return bs.out<string>();
@@ -119,8 +122,8 @@ export namespace JSON {
119
122
 
120
123
  store<u16>(changetype<usize>(out), QUOTE);
121
124
  memory.copy(changetype<usize>(out) + 2, changetype<usize>(data.toISOString()), 48);
122
- store<u16>(changetype<usize>(out), 50);
123
- return out;
125
+ store<u16>(changetype<usize>(out), QUOTE, 50);
126
+ return changetype<string>(out);
124
127
  } else if (data instanceof Array) {
125
128
  // @ts-ignore
126
129
  serializeArray(changetype<nonnull<T>>(data));
@@ -135,7 +138,7 @@ export namespace JSON {
135
138
  } else if (data instanceof JSON.Box) {
136
139
  return JSON.stringify(data.value);
137
140
  } else {
138
- ERROR(`Could not serialize data of type ${nameof<T>()}. Make sure to add the correct decorators to classes.`);
141
+ throw new Error(`Could not serialize data of type ${nameof<T>()}. Make sure to add the correct decorators to classes.`);
139
142
  }
140
143
  }
141
144
 
@@ -156,12 +159,12 @@ export namespace JSON {
156
159
  return deserializeInteger<T>(dataPtr, dataPtr + dataSize);
157
160
  } else if (isFloat<T>()) {
158
161
  return deserializeFloat<T>(dataPtr, dataPtr + dataSize);
159
- } else if (isNullable<T>() && data.length == 4 && data == "null") {
162
+ } else if (isNullable<T>() && dataSize == 8 && load<u64>(dataPtr) == 30399761348886638) {
160
163
  // @ts-ignore
161
164
  return null;
162
165
  } else if (isString<T>()) {
163
166
  // @ts-ignore
164
- return deserializeString(dataPtr, dataPtr + dataSize);
167
+ return deserializeString(dataPtr, dataPtr + dataSize, __new(dataSize - 4, idof<string>()));
165
168
  } else if (isArray<T>()) {
166
169
  // @ts-ignore
167
170
  return deserializeArray<nonnull<T>>(dataPtr, dataPtr + dataSize, changetype<usize>(instantiate<T>()));
@@ -182,9 +185,9 @@ export namespace JSON {
182
185
  return deserializeDate(dataPtr, dataPtr + dataSize);
183
186
  } else if (type instanceof JSON.Box) {
184
187
  // @ts-ignore
185
- return new JSON.Box(JSON.parse<indexof<T>>(data));
188
+ return new JSON.Box(parseBox(data, changetype<nonnull<T>>(0).value));
186
189
  } else {
187
- ERROR(`Could not deserialize data ${data} to type ${nameof<T>()}. Make sure to add the correct decorators to classes.`);
190
+ throw new Error(`Could not deserialize data ${data} to type ${nameof<T>()}. Make sure to add the correct decorators to classes.`);
188
191
  }
189
192
  }
190
193
 
@@ -339,7 +342,9 @@ export namespace JSON {
339
342
  * Box for primitive types
340
343
  */
341
344
  export class Box<T> {
342
- constructor(public value: T) {}
345
+ constructor(public value: T) {
346
+ if (!isInteger<T>() && !isFloat<T>()) ERROR("JSON.Box should only hold primitive types!");
347
+ }
343
348
  /**
344
349
  * Creates a reference to a primitive type
345
350
  * This means that it can create a nullable primitive
@@ -353,13 +358,19 @@ export namespace JSON {
353
358
  @inline static from<T>(value: T): Box<T> {
354
359
  return new Box(value);
355
360
  }
361
+ toString(): string {
362
+ if (isNullable<this>() && changetype<usize>(this) == null) return "null";
363
+ // @ts-ignore: type
364
+ if (isDefined(this.value.toString)) return this.value.toString();
365
+ return "null";
366
+ }
356
367
  }
357
368
 
358
369
  export function __serialize<T>(src: T): void {
359
370
  if (isBoolean<T>()) {
360
371
  serializeBool(src as bool);
361
372
  } else if (isInteger<T>() && nameof<T>() == "usize" && src == 0) {
362
- bs.ensureSize(8);
373
+ bs.proposeSize(8);
363
374
  store<u64>(bs.offset, 30399761348886638);
364
375
  bs.offset += 8;
365
376
  } else if (isInteger<T>()) {
@@ -370,7 +381,7 @@ export namespace JSON {
370
381
  serializeFloat<T>(src);
371
382
  // @ts-ignore: Function is generated by transform
372
383
  } else if (isNullable<T>() && changetype<usize>(src) == <usize>0) {
373
- bs.ensureSize(8);
384
+ bs.proposeSize(8);
374
385
  store<u64>(bs.offset, 30399761348886638);
375
386
  bs.offset += 8;
376
387
  } else if (isString<nonnull<T>>()) {
@@ -393,7 +404,7 @@ export namespace JSON {
393
404
  } else if (src instanceof JSON.Box) {
394
405
  __serialize(src.value);
395
406
  } else {
396
- ERROR(`Could not serialize provided data. Make sure to add the correct decorators to classes.`);
407
+ throw new Error(`Could not serialize provided data. Make sure to add the correct decorators to classes.`);
397
408
  }
398
409
  }
399
410
  export function __deserialize<T>(srcStart: usize, srcEnd: usize, dst: usize = 0): T {
@@ -421,8 +432,20 @@ export namespace JSON {
421
432
  } else if (type instanceof Date) {
422
433
  // @ts-ignore: type
423
434
  return deserializeDate(srcStart, srcEnd);
435
+ } else if (type instanceof JSON.Box) {
436
+ // @ts-ignore: type
437
+ return new JSON.Box(deserializeBox(srcStart, srcEnd, dst, changetype<nonnull<T>>(0).value));
424
438
  }
425
439
  }
426
440
  throw new Error(`Could not deserialize data '${ptrToStr(srcStart, srcEnd).slice(0, 100)}' to type. Make sure to add the correct decorators to classes.`);
427
441
  }
428
442
  }
443
+
444
+ // @ts-ignore: decorator
445
+ @inline function parseBox<T>(data: string, ty: T): T {
446
+ return JSON.parse<T>(data);
447
+ }
448
+
449
+ function deserializeBox<T>(srcStart: usize, srcEnd: usize, dst: usize, ty: T): T {
450
+ return JSON.__deserialize<T>(srcStart, srcEnd, dst);
451
+ }