json-as 0.9.20 → 0.9.22

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.
@@ -0,0 +1,4 @@
1
+ {
2
+ "singleQuote": false,
3
+ "printWidth": 65536
4
+ }
package/CHANGELOG CHANGED
@@ -28,6 +28,7 @@ v0.9.17 - A schema's parent's fields should be included properly
28
28
  v0.9.18 - Should be able to use @alias and @omit*** or JSON.Raw
29
29
  v0.9.19 - Fix arguments in @omitif declarations not working properly
30
30
  v0.9.20 - Strings were being received with quotes attached via the toString functionality. Removed that.
31
+ v0.9.22 - Fix #89 and #93. Several bug fixes some severe such as ",null" being prepended when using @omit. Properly warn when a schema has fields that are not compatible with json
31
32
 
32
33
  [UNRELEASED] v1.0.0
33
34
  - Allow nullable primitives
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  __| || __|| || | | ___ | _ || __|
4
4
  | | ||__ || | || | | ||___|| ||__ |
5
5
  |_____||_____||_____||_|___| |__|__||_____|
6
- v0.9.20
6
+ v0.9.22
7
7
  </pre>
8
8
  </h5>
9
9
 
@@ -107,25 +107,16 @@ const serialized = JSON.stringify(arr);
107
107
  const parsed = JSON.parse<Base[]>(serialized);
108
108
  ```
109
109
 
110
- Classes can even have inheritance. Here's a nasty example
111
-
112
- ```js
113
- @json
114
- class Base {}
115
-
116
- const serialized = JSON.stringify(arr);
117
- // [{"x":1.0},{"x":1.0,"y":2.0},{"y":2.0,"x":1.0,"z":3.0}]
118
- const parsed = JSON.parse<Base[]>(serialized);
119
- ```
120
-
121
110
  You can also add it to your `asconfig.json`
122
111
 
112
+ ```json
123
113
  {
124
- // ...
125
- "options": {
126
- "transform": ["json-as/transform"]
127
- }
114
+ // ...
115
+ "options": {
116
+ "transform": ["json-as/transform"]
117
+ }
128
118
  }
119
+ ```
129
120
 
130
121
  If you use this project in your codebase, consider dropping a [star](https://github.com/JairusSW/as-json). I would really appreciate it!
131
122
 
@@ -0,0 +1 @@
1
+ /// <reference types="@as-tral/cli/as-tral" />
@@ -0,0 +1,14 @@
1
+ // import { bs } from "../custom/bs";
2
+ // import { serializeBool, serializeBool_BS } from "../serialize/bool"
3
+
4
+ // const out = memory.data(65536);
5
+
6
+ // bench("Serialize Bool", () => {
7
+ // blackbox<string>(serializeBool(true));
8
+ // });
9
+
10
+ // bench("Serialize Bool BS", () => {
11
+ // serializeBool_BS(true);
12
+ // bs._out(out);
13
+ // bs.reset();
14
+ // });
@@ -0,0 +1,36 @@
1
+ // function esc_128(data: string): bool {
2
+ // let len = data.length;
3
+
4
+ // let running = v128.splat<i64>(0);
5
+ // let i = 0;
6
+
7
+ // while (i + 15 < len) {
8
+ // let w = v128.load(changetype<usize>(data));
9
+ // running = v128.or(running, v128.eq<i16>(w, i16x8.splat(34)));
10
+ // running = v128.or(running, v128.eq<i16>(w, i16x8.splat(92)));
11
+
12
+ // const subtracted = v128.sub<i16>(w, i8x16.splat(31));
13
+ // running = v128.or(running, v128.eq<i16>(subtracted, v128.splat<i64>(0)));
14
+ // i += 16;
15
+ // }
16
+
17
+ // return v128.any_true(running);
18
+ // }
19
+
20
+ // function esc_16(data: string): bool {
21
+ // let len = data.length;
22
+ // let b: u16 = 0;
23
+ // while (len--) {
24
+ // const c = load<u16>(changetype<usize>(data) + (len << 1));
25
+ // b |= u16(c < 32) | u16(c == 34) | u16(c == 92);
26
+ // }
27
+ // return bool(b);
28
+ // }
29
+
30
+ // bench("needs escaping 128", () => {
31
+ // blackbox<bool>(esc_128("hel\"o !!"));
32
+ // })
33
+
34
+ // bench("needs escaping 16", () => {
35
+ // blackbox<bool>(esc_16("hel\"o !!"));
36
+ // })
@@ -0,0 +1,21 @@
1
+ import { bs } from "../custom/bs";
2
+ import { serializeBool, serializeBool_BS } from "../serialize/bool";
3
+ import { serialize_simd_v1, serializeString, serializeString_BS } from "../serialize/string";
4
+
5
+ const out = memory.data(65536);
6
+
7
+ bench("UTF-16 to UTF-8", () => {
8
+ blackbox<ArrayBuffer>(String.UTF8.encode(blackbox<string>("hello world")));
9
+ });
10
+ // bench("Serialize String Native", () => {
11
+ // blackbox<string>(serializeString("hello \"world abc"));
12
+ // });
13
+
14
+ // bench("Serialize String Sink", () => {
15
+ // serializeString_BS("hello \"world abc");
16
+ // bs.reset();
17
+ // });
18
+
19
+ // bench("Serialize String SIMD", () => {
20
+ // serialize_simd_v1("hello \"world abc", out);
21
+ // })
@@ -0,0 +1,20 @@
1
+ import { JSON } from "json-as";
2
+ import { describe, expect, run } from "as-test/assembly";
3
+
4
+ describe("Should serialize booleans", () => {
5
+ expect(JSON.stringify<bool>(true)).toBe("true");
6
+
7
+ expect(JSON.stringify<bool>(false)).toBe("false");
8
+
9
+ expect(JSON.stringify<boolean>(true)).toBe("true");
10
+
11
+ expect(JSON.stringify<boolean>(false)).toBe("false");
12
+ });
13
+
14
+ describe("Should deserialize booleans", () => {
15
+ expect(JSON.parse<boolean>("true")).toBe(true);
16
+
17
+ expect(JSON.parse<boolean>("false")).toBe(false);
18
+ });
19
+
20
+ run();
@@ -0,0 +1,52 @@
1
+ import { JSON } from "json-as";
2
+ import { describe, expect, run } from "as-test/assembly";
3
+
4
+ describe("Should serialize floats", () => {
5
+ expect(JSON.stringify<f64>(7.23)).toBe("7.23");
6
+
7
+ expect(JSON.stringify<f64>(10e2)).toBe("1000.0");
8
+
9
+ expect(JSON.stringify<f64>(123456e-5)).toBe("1.23456");
10
+
11
+ expect(JSON.stringify<f64>(0.0)).toBe("0.0");
12
+
13
+ expect(JSON.stringify<f64>(-7.23)).toBe("-7.23");
14
+
15
+ expect(JSON.stringify<f64>(1e-6)).toBe("0.000001");
16
+
17
+ expect(JSON.stringify<f64>(1e-7)).toBe("1e-7");
18
+
19
+ expect(JSON.parse<f64>("1E-7")).toBe(1e-7);
20
+
21
+ expect(JSON.stringify<f64>(1e20)).toBe("100000000000000000000.0");
22
+
23
+ expect(JSON.stringify<f64>(1e21)).toBe("1e+21");
24
+
25
+ expect(JSON.parse<f64>("1E+21")).toBe(1e21);
26
+
27
+ expect(JSON.parse<f64>("1e21")).toBe(1e21);
28
+
29
+ expect(JSON.parse<f64>("1E21")).toBe(1e21);
30
+ });
31
+
32
+ describe("Should deserialize floats", () => {
33
+ expect(JSON.parse<f64>("7.23")).toBe(7.23);
34
+
35
+ expect(JSON.parse<f64>("1000.0")).toBe(1000.0);
36
+
37
+ expect(JSON.parse<f64>("1.23456")).toBe(1.23456);
38
+
39
+ expect(JSON.parse<f64>("0.0")).toBe(0.0);
40
+
41
+ expect(JSON.parse<f64>("-7.23")).toBe(-7.23);
42
+
43
+ expect(JSON.parse<f64>("0.000001")).toBe(0.000001);
44
+
45
+ expect(JSON.parse<f64>("1e-7")).toBe(1e-7);
46
+
47
+ expect(JSON.parse<f64>("100000000000000000000.0")).toBe(1e20);
48
+
49
+ expect(JSON.parse<f64>("1e+21")).toBe(1e21);
50
+ });
51
+
52
+ run();
@@ -0,0 +1,28 @@
1
+ import { JSON } from "json-as";
2
+ import { describe, expect, run } from "as-test/assembly";
3
+
4
+ describe("Should serialize integers", () => {
5
+ expect(JSON.stringify(0)).toBe("0");
6
+
7
+ expect(JSON.stringify<u32>(100)).toBe("100");
8
+
9
+ expect(JSON.stringify<u64>(101)).toBe("101");
10
+
11
+ expect(JSON.stringify<i32>(-100)).toBe("-100");
12
+
13
+ expect(JSON.stringify<i64>(-101)).toBe("-101");
14
+ });
15
+
16
+ describe("Should deserialize integers", () => {
17
+ expect(JSON.parse<i32>("0")).toBe(<i32>0);
18
+
19
+ expect(JSON.parse<u32>("100")).toBe(<u32>100);
20
+
21
+ expect(JSON.parse<u64>("101")).toBe(<u64>101);
22
+
23
+ expect(JSON.parse<i32>("-100")).toBe(<i32>-100);
24
+
25
+ expect(JSON.parse<i64>("-101")).toBe(<i64>-101);
26
+ });
27
+
28
+ run();
@@ -0,0 +1,4 @@
1
+ import { JSON } from "json-as";
2
+ import { describe, expect, run } from "as-test/assembly";
3
+
4
+ run();
@@ -0,0 +1,24 @@
1
+ import { JSON } from "json-as";
2
+ import { describe, expect, run } from "as-test/assembly";
3
+
4
+ describe("Should serialize strings", () => {
5
+ expect(JSON.stringify("abcdefg")).toBe('"abcdefg"');
6
+
7
+ expect(JSON.stringify('st"ring" w""ith quotes"')).toBe('"st\\"ring\\" w\\"\\"ith quotes\\""');
8
+
9
+ expect(JSON.stringify('string "with random spa\nces and \nnewlines\n\n\n')).toBe('"string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"');
10
+
11
+ expect(JSON.stringify('string with colon : comma , brace [ ] bracket { } and quote " and other quote \\"')).toBe('"string with colon : comma , brace [ ] bracket { } and quote \\" and other quote \\\\\\""');
12
+ });
13
+
14
+ describe("Should deserialize strings", () => {
15
+ expect(JSON.parse<string>('"abcdefg"')).toBe("abcdefg");
16
+
17
+ expect(JSON.parse<string>('"\\"st\\\\\\"ring\\\\\\" w\\\\\\"\\\\\\"ith quotes\\\\\\"\\""')).toBe('"st\\"ring\\" w\\"\\"ith quotes\\""');
18
+
19
+ expect(JSON.parse<string>('"\\"string \\\\\\"with random spa\\\\nces and \\\\nnewlines\\\\n\\\\n\\\\n\\""')).toBe('"string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"');
20
+
21
+ expect(JSON.parse<string>('"\\"string with colon : comma , brace [ ] bracket { } and quote \\\\\\" and other quote \\\\\\\\\\"\\""')).toBe('"string with colon : comma , brace [ ] bracket { } and quote \\" and other quote \\\\""');
22
+ });
23
+
24
+ run();
@@ -1,84 +1,6 @@
1
1
  import { JSON } from "json-as";
2
2
  import { describe, expect, run } from "as-test/assembly";
3
- import {
4
- DerivedObject,
5
- Null,
6
- ObjWithStrangeKey,
7
- ObjectWithFloat,
8
- OmitIf,
9
- Player,
10
- Vec3,
11
- } from "./types";
12
-
13
- describe("Should serialize strings", () => {
14
- expect(JSON.stringify("abcdefg")).toBe('"abcdefg"');
15
-
16
- expect(JSON.stringify('st"ring" w""ith quotes"')).toBe(
17
- '"st\\"ring\\" w\\"\\"ith quotes\\""',
18
- );
19
-
20
- expect(
21
- JSON.stringify('string "with random spa\nces and \nnewlines\n\n\n'),
22
- ).toBe('"string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"');
23
-
24
- expect(
25
- JSON.stringify(
26
- 'string with colon : comma , brace [ ] bracket { } and quote " and other quote \\"',
27
- ),
28
- ).toBe(
29
- '"string with colon : comma , brace [ ] bracket { } and quote \\" and other quote \\\\\\""',
30
- );
31
- });
32
-
33
- describe("Should serialize integers", () => {
34
- expect(JSON.stringify(0)).toBe("0");
35
-
36
- expect(JSON.stringify<u32>(100)).toBe("100");
37
-
38
- expect(JSON.stringify<u64>(101)).toBe("101");
39
-
40
- expect(JSON.stringify<i32>(-100)).toBe("-100");
41
-
42
- expect(JSON.stringify<i64>(-101)).toBe("-101");
43
- });
44
-
45
- describe("Should serialize floats", () => {
46
- expect(JSON.stringify<f64>(7.23)).toBe("7.23");
47
-
48
- expect(JSON.stringify<f64>(10e2)).toBe("1000.0");
49
-
50
- expect(JSON.stringify<f64>(123456e-5)).toBe("1.23456");
51
-
52
- expect(JSON.stringify<f64>(0.0)).toBe("0.0");
53
-
54
- expect(JSON.stringify<f64>(-7.23)).toBe("-7.23");
55
-
56
- expect(JSON.stringify<f64>(1e-6)).toBe("0.000001");
57
-
58
- expect(JSON.stringify<f64>(1e-7)).toBe("1e-7");
59
-
60
- expect(JSON.parse<f64>("1E-7")).toBe(1e-7);
61
-
62
- expect(JSON.stringify<f64>(1e20)).toBe("100000000000000000000.0");
63
-
64
- expect(JSON.stringify<f64>(1e21)).toBe("1e+21");
65
-
66
- expect(JSON.parse<f64>("1E+21")).toBe(1e21);
67
-
68
- expect(JSON.parse<f64>("1e21")).toBe(1e21);
69
-
70
- expect(JSON.parse<f64>("1E21")).toBe(1e21);
71
- });
72
-
73
- describe("Should serialize booleans", () => {
74
- expect(JSON.stringify<bool>(true)).toBe("true");
75
-
76
- expect(JSON.stringify<bool>(false)).toBe("false");
77
-
78
- expect(JSON.stringify<boolean>(true)).toBe("true");
79
-
80
- expect(JSON.stringify<boolean>(false)).toBe("false");
81
- });
3
+ import { DerivedObject, Null, ObjWithStrangeKey, ObjectWithFloat, OmitIf, Player, Vec3 } from "./types";
82
4
 
83
5
  describe("Should serialize class inheritance", () => {
84
6
  const obj = new DerivedObject("1", "2");
@@ -95,23 +17,15 @@ describe("Should serialize integer arrays", () => {
95
17
 
96
18
  expect(JSON.stringify<u64[]>([0, 100, 101])).toBe("[0,100,101]");
97
19
 
98
- expect(JSON.stringify<i32[]>([0, 100, 101, -100, -101])).toBe(
99
- "[0,100,101,-100,-101]",
100
- );
20
+ expect(JSON.stringify<i32[]>([0, 100, 101, -100, -101])).toBe("[0,100,101,-100,-101]");
101
21
 
102
- expect(JSON.stringify<i64[]>([0, 100, 101, -100, -101])).toBe(
103
- "[0,100,101,-100,-101]",
104
- );
22
+ expect(JSON.stringify<i64[]>([0, 100, 101, -100, -101])).toBe("[0,100,101,-100,-101]");
105
23
  });
106
24
 
107
25
  describe("Should serialize float arrays", () => {
108
- expect(
109
- JSON.stringify<f64[]>([7.23, 10e2, 10e2, 123456e-5, 123456e-5, 0.0, 7.23]),
110
- ).toBe("[7.23,1000.0,1000.0,1.23456,1.23456,0.0,7.23]");
26
+ expect(JSON.stringify<f64[]>([7.23, 10e2, 10e2, 123456e-5, 123456e-5, 0.0, 7.23])).toBe("[7.23,1000.0,1000.0,1.23456,1.23456,0.0,7.23]");
111
27
 
112
- expect(JSON.stringify<f64[]>([1e21, 1e22, 1e-7, 1e-8, 1e-9])).toBe(
113
- "[1e+21,1e+22,1e-7,1e-8,1e-9]",
114
- );
28
+ expect(JSON.stringify<f64[]>([1e21, 1e22, 1e-7, 1e-8, 1e-9])).toBe("[1e+21,1e+22,1e-7,1e-8,1e-9]");
115
29
  });
116
30
 
117
31
  describe("Should serialize boolean arrays", () => {
@@ -121,39 +35,21 @@ describe("Should serialize boolean arrays", () => {
121
35
  });
122
36
 
123
37
  describe("Should serialize string arrays", () => {
124
- expect(
125
- JSON.stringify<string[]>([
126
- 'string "with random spa\nces and \nnewlines\n\n\n',
127
- ]),
128
- ).toBe('["string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"]');
38
+ expect(JSON.stringify<string[]>(['string "with random spa\nces and \nnewlines\n\n\n'])).toBe('["string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"]');
129
39
  });
130
40
 
131
41
  describe("Should serialize nested integer arrays", () => {
132
- expect(JSON.stringify<i64[][]>([[100, 101], [-100, -101], [0]])).toBe(
133
- "[[100,101],[-100,-101],[0]]",
134
- );
42
+ expect(JSON.stringify<i64[][]>([[100, 101], [-100, -101], [0]])).toBe("[[100,101],[-100,-101],[0]]");
135
43
  });
136
44
 
137
45
  describe("Should serialize nested float arrays", () => {
138
- expect(
139
- JSON.stringify<f64[][]>([
140
- [7.23],
141
- [10e2],
142
- [10e2],
143
- [123456e-5],
144
- [123456e-5],
145
- [0.0],
146
- [7.23],
147
- ]),
148
- ).toBe("[[7.23],[1000.0],[1000.0],[1.23456],[1.23456],[0.0],[7.23]]");
46
+ expect(JSON.stringify<f64[][]>([[7.23], [10e2], [10e2], [123456e-5], [123456e-5], [0.0], [7.23]])).toBe("[[7.23],[1000.0],[1000.0],[1.23456],[1.23456],[0.0],[7.23]]");
149
47
  });
150
48
 
151
49
  describe("Should serialize nested boolean arrays", () => {
152
50
  expect(JSON.stringify<bool[][]>([[true], [false]])).toBe("[[true],[false]]");
153
51
 
154
- expect(JSON.stringify<boolean[][]>([[true], [false]])).toBe(
155
- "[[true],[false]]",
156
- );
52
+ expect(JSON.stringify<boolean[][]>([[true], [false]])).toBe("[[true],[false]]");
157
53
  });
158
54
 
159
55
  describe("Should serialize object arrays", () => {
@@ -195,27 +91,19 @@ describe("Should serialize objects", () => {
195
91
  },
196
92
  isVerified: true,
197
93
  }),
198
- ).toBe(
199
- '{"firstName":"Emmet","lastName":"West","lastActive":[8,27,2022],"age":23,"pos":{"x":3.4,"y":1.2,"z":8.3},"isVerified":true}',
200
- );
94
+ ).toBe('{"firstName":"Emmet","lastName":"West","lastActive":[8,27,2022],"age":23,"pos":{"x":3.4,"y":1.2,"z":8.3},"isVerified":true}');
201
95
 
202
96
  expect(JSON.stringify<ObjectWithFloat>({ f: 7.23 })).toBe('{"f":7.23}');
203
97
 
204
- expect(JSON.stringify<ObjectWithFloat>({ f: 0.000001 })).toBe(
205
- '{"f":0.000001}',
206
- );
98
+ expect(JSON.stringify<ObjectWithFloat>({ f: 0.000001 })).toBe('{"f":0.000001}');
207
99
 
208
100
  expect(JSON.stringify<ObjectWithFloat>({ f: 1e-7 })).toBe('{"f":1e-7}');
209
101
 
210
- expect(JSON.stringify<ObjectWithFloat>({ f: 1e20 })).toBe(
211
- '{"f":100000000000000000000.0}',
212
- );
102
+ expect(JSON.stringify<ObjectWithFloat>({ f: 1e20 })).toBe('{"f":100000000000000000000.0}');
213
103
 
214
104
  expect(JSON.stringify<ObjectWithFloat>({ f: 1e21 })).toBe('{"f":1e+21}');
215
105
 
216
- expect(JSON.stringify<ObjWithStrangeKey<string>>({ data: "foo" })).toBe(
217
- '{"a\\\\\\t\\"\\u0002b`c":"foo"}',
218
- );
106
+ expect(JSON.stringify<ObjWithStrangeKey<string>>({ data: "foo" })).toBe('{"a\\\\\\t\\"\\u0002b`c":"foo"}');
219
107
  });
220
108
 
221
109
  describe("Should serialize @omit'ed objects", () => {
@@ -225,69 +113,6 @@ describe("Should serialize @omit'ed objects", () => {
225
113
  }),
226
114
  ).toBe('{"x":1,"y":1,"z":1}');
227
115
  });
228
-
229
- describe("Should deserialize strings", () => {
230
- expect(JSON.parse<string>('"abcdefg"')).toBe("abcdefg");
231
-
232
- expect(
233
- JSON.parse<string>(
234
- '"\\"st\\\\\\"ring\\\\\\" w\\\\\\"\\\\\\"ith quotes\\\\\\"\\""',
235
- ),
236
- ).toBe('"st\\"ring\\" w\\"\\"ith quotes\\""');
237
-
238
- expect(
239
- JSON.parse<string>(
240
- '"\\"string \\\\\\"with random spa\\\\nces and \\\\nnewlines\\\\n\\\\n\\\\n\\""',
241
- ),
242
- ).toBe('"string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"');
243
-
244
- expect(
245
- JSON.parse<string>(
246
- '"\\"string with colon : comma , brace [ ] bracket { } and quote \\\\\\" and other quote \\\\\\\\\\"\\""',
247
- ),
248
- ).toBe(
249
- '"string with colon : comma , brace [ ] bracket { } and quote \\" and other quote \\\\""',
250
- );
251
- });
252
-
253
- describe("Should deserialize integers", () => {
254
- expect(JSON.parse<i32>("0")).toBe(<i32>0);
255
-
256
- expect(JSON.parse<u32>("100")).toBe(<u32>100);
257
-
258
- expect(JSON.parse<u64>("101")).toBe(<u64>101);
259
-
260
- expect(JSON.parse<i32>("-100")).toBe(<i32>-100);
261
-
262
- expect(JSON.parse<i64>("-101")).toBe(<i64>-101);
263
- });
264
-
265
- describe("Should deserialize floats", () => {
266
- expect(JSON.parse<f64>("7.23")).toBe(7.23);
267
-
268
- expect(JSON.parse<f64>("1000.0")).toBe(1000.0);
269
-
270
- expect(JSON.parse<f64>("1.23456")).toBe(1.23456);
271
-
272
- expect(JSON.parse<f64>("0.0")).toBe(0.0);
273
-
274
- expect(JSON.parse<f64>("-7.23")).toBe(-7.23);
275
-
276
- expect(JSON.parse<f64>("0.000001")).toBe(0.000001);
277
-
278
- expect(JSON.parse<f64>("1e-7")).toBe(1e-7);
279
-
280
- expect(JSON.parse<f64>("100000000000000000000.0")).toBe(1e20);
281
-
282
- expect(JSON.parse<f64>("1e+21")).toBe(1e21);
283
- });
284
-
285
- describe("Should deserialize booleans", () => {
286
- expect(JSON.parse<boolean>("true")).toBe(true);
287
-
288
- expect(JSON.parse<boolean>("false")).toBe(false);
289
- });
290
-
291
116
  describe("Should deserialize class inheritance", () => {
292
117
  const jsonStr = '{"a":"1","b":"2"}';
293
118
  const obj = JSON.parse<DerivedObject>(jsonStr);
@@ -302,83 +127,39 @@ describe("Should deserialize nulls", () => {
302
127
  });
303
128
 
304
129
  describe("Should deserialize integer arrays", () => {
305
- expect(JSON.stringify(JSON.parse<u32[]>("[0,100,101]"))).toBe(
306
- JSON.stringify([0, 100, 101]),
307
- );
130
+ expect(JSON.stringify(JSON.parse<u32[]>("[0,100,101]"))).toBe(JSON.stringify([0, 100, 101]));
308
131
 
309
- expect(JSON.stringify(JSON.parse<i32[]>("[0,100,101,-100,-101]"))).toBe(
310
- JSON.stringify([0, 100, 101, -100, -101]),
311
- );
132
+ expect(JSON.stringify(JSON.parse<i32[]>("[0,100,101,-100,-101]"))).toBe(JSON.stringify([0, 100, 101, -100, -101]));
312
133
  });
313
134
 
314
135
  describe("Should deserialize float arrays", () => {
315
- expect(
316
- JSON.stringify(
317
- JSON.parse<f64[]>("[7.23,1000.0,1000.0,1.23456,1.23456,0.0,7.23]"),
318
- ),
319
- ).toBe(JSON.stringify([7.23, 1000.0, 1000.0, 1.23456, 1.23456, 0.0, 7.23]));
136
+ expect(JSON.stringify(JSON.parse<f64[]>("[7.23,1000.0,1000.0,1.23456,1.23456,0.0,7.23]"))).toBe(JSON.stringify([7.23, 1000.0, 1000.0, 1.23456, 1.23456, 0.0, 7.23]));
320
137
 
321
- expect(
322
- JSON.stringify(JSON.parse<f64[]>("[1e+21,1e+22,1e-7,1e-8,1e-9]")),
323
- ).toBe(JSON.stringify([1e21, 1e22, 1e-7, 1e-8, 1e-9]));
138
+ expect(JSON.stringify(JSON.parse<f64[]>("[1e+21,1e+22,1e-7,1e-8,1e-9]"))).toBe(JSON.stringify([1e21, 1e22, 1e-7, 1e-8, 1e-9]));
324
139
  });
325
140
 
326
141
  describe("Should deserialize boolean arrays", () => {
327
- expect(JSON.stringify(JSON.parse<boolean[]>("[true,false]"))).toBe(
328
- JSON.stringify([true, false]),
329
- );
142
+ expect(JSON.stringify(JSON.parse<boolean[]>("[true,false]"))).toBe(JSON.stringify([true, false]));
330
143
  });
331
144
 
332
145
  describe("Should deserialize string arrays", () => {
333
- expect(
334
- JSON.stringify(
335
- JSON.parse<string[]>(
336
- '["string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"]',
337
- ),
338
- ),
339
- ).toBe(JSON.stringify(['string "with random spa\nces and \nnewlines\n\n\n']));
146
+ expect(JSON.stringify(JSON.parse<string[]>('["string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"]'))).toBe(JSON.stringify(['string "with random spa\nces and \nnewlines\n\n\n']));
340
147
  });
341
148
 
342
149
  describe("Should deserialize nested integer arrays", () => {
343
- expect(
344
- JSON.stringify(JSON.parse<i64[][]>("[[100,101],[-100,-101],[0]]")),
345
- ).toBe(JSON.stringify([[100, 101], [-100, -101], [0]]));
150
+ expect(JSON.stringify(JSON.parse<i64[][]>("[[100,101],[-100,-101],[0]]"))).toBe(JSON.stringify([[100, 101], [-100, -101], [0]]));
346
151
  });
347
152
 
348
153
  describe("Should deserialize nested float arrays", () => {
349
- expect(
350
- JSON.stringify(
351
- JSON.parse<f64[][]>(
352
- "[[7.23],[1000.0],[1000.0],[1.23456],[1.23456],[0.0],[7.23]]",
353
- ),
354
- ),
355
- ).toBe(
356
- JSON.stringify([
357
- [7.23],
358
- [1000.0],
359
- [1000.0],
360
- [1.23456],
361
- [1.23456],
362
- [0.0],
363
- [7.23],
364
- ]),
365
- );
154
+ expect(JSON.stringify(JSON.parse<f64[][]>("[[7.23],[1000.0],[1000.0],[1.23456],[1.23456],[0.0],[7.23]]"))).toBe(JSON.stringify([[7.23], [1000.0], [1000.0], [1.23456], [1.23456], [0.0], [7.23]]));
366
155
  });
367
156
 
368
157
  describe("Should deserialize nested boolean arrays", () => {
369
- expect(JSON.stringify(JSON.parse<boolean[][]>("[[true],[false]]"))).toBe(
370
- JSON.stringify([[true], [false]]),
371
- );
158
+ expect(JSON.stringify(JSON.parse<boolean[][]>("[[true],[false]]"))).toBe(JSON.stringify([[true], [false]]));
372
159
  });
373
160
 
374
161
  describe("Should deserialize object arrays", () => {
375
- expect(
376
- JSON.stringify(
377
- JSON.parse<Vec3[]>(
378
- '[{"x":3.4,"y":1.2,"z":8.3},{"x":3.4,"y":-2.1,"z":9.3}]',
379
- ),
380
- ),
381
- ).toBe(
162
+ expect(JSON.stringify(JSON.parse<Vec3[]>('[{"x":3.4,"y":1.2,"z":8.3},{"x":3.4,"y":-2.1,"z":9.3}]'))).toBe(
382
163
  JSON.stringify(<Vec3[]>[
383
164
  { x: 3.4, y: 1.2, z: 8.3 },
384
165
  { x: 3.4, y: -2.1, z: 9.3 },
@@ -387,17 +168,9 @@ describe("Should deserialize object arrays", () => {
387
168
  });
388
169
 
389
170
  describe("Should deserialize Objects", () => {
390
- expect(JSON.stringify(JSON.parse<Vec3>('{"x":3.4,"y":1.2,"z":8.3}'))).toBe(
391
- JSON.stringify(<Vec3>{ x: 3.4, y: 1.2, z: 8.3 }),
392
- );
171
+ expect(JSON.stringify(JSON.parse<Vec3>('{"x":3.4,"y":1.2,"z":8.3}'))).toBe(JSON.stringify(<Vec3>{ x: 3.4, y: 1.2, z: 8.3 }));
393
172
 
394
- expect(
395
- JSON.stringify(
396
- JSON.parse<Player>(
397
- '{"firstName":"Emmet","lastName":"West","lastActive":[8,27,2022],"age":23,"pos":{"x":3.4,"y":1.2,"z":8.3},"isVerified":true}',
398
- ),
399
- ),
400
- ).toBe(
173
+ expect(JSON.stringify(JSON.parse<Player>('{"firstName":"Emmet","lastName":"West","lastActive":[8,27,2022],"age":23,"pos":{"x":3.4,"y":1.2,"z":8.3},"isVerified":true}'))).toBe(
401
174
  JSON.stringify(<Player>{
402
175
  firstName: "Emmet",
403
176
  lastName: "West",
@@ -408,19 +181,11 @@ describe("Should deserialize Objects", () => {
408
181
  }),
409
182
  );
410
183
 
411
- expect(JSON.stringify(JSON.parse<ObjectWithFloat>('{"f":7.23}'))).toBe(
412
- JSON.stringify(<ObjectWithFloat>{ f: 7.23 }),
413
- );
184
+ expect(JSON.stringify(JSON.parse<ObjectWithFloat>('{"f":7.23}'))).toBe(JSON.stringify(<ObjectWithFloat>{ f: 7.23 }));
414
185
 
415
- expect(JSON.stringify(JSON.parse<ObjectWithFloat>('{"f":0.000001}'))).toBe(
416
- JSON.stringify(<ObjectWithFloat>{ f: 0.000001 }),
417
- );
186
+ expect(JSON.stringify(JSON.parse<ObjectWithFloat>('{"f":0.000001}'))).toBe(JSON.stringify(<ObjectWithFloat>{ f: 0.000001 }));
418
187
 
419
- expect(
420
- JSON.stringify(
421
- JSON.parse<ObjWithStrangeKey<string>>('{"a\\\\\\t\\"\\u0002b`c":"foo"}'),
422
- ),
423
- ).toBe(JSON.stringify(<ObjWithStrangeKey<string>>{ data: "foo" }));
188
+ expect(JSON.stringify(JSON.parse<ObjWithStrangeKey<string>>('{"a\\\\\\t\\"\\u0002b`c":"foo"}'))).toBe(JSON.stringify(<ObjWithStrangeKey<string>>{ data: "foo" }));
424
189
  });
425
190
 
426
191
  run({