json-as 0.9.21 → 0.9.23

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,7 +28,8 @@ 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.21 - Fix #89
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
32
+ v0.9.23 - Comment out SIMD-related code for now
32
33
 
33
34
  [UNRELEASED] v1.0.0
34
35
  - Allow nullable primitives
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  __| || __|| || | | ___ | _ || __|
4
4
  | | ||__ || | || | | ||___|| ||__ |
5
5
  |_____||_____||_____||_|___| |__|__||_____|
6
- v0.9.21
6
+ v0.9.23
7
7
  </pre>
8
8
  </h5>
9
9
 
@@ -116,7 +116,7 @@ You can also add it to your `asconfig.json`
116
116
  "transform": ["json-as/transform"]
117
117
  }
118
118
  }
119
- ````
119
+ ```
120
120
 
121
121
  If you use this project in your codebase, consider dropping a [star](https://github.com/JairusSW/as-json). I would really appreciate it!
122
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
+ // })
@@ -2,19 +2,19 @@ import { JSON } from "json-as";
2
2
  import { describe, expect, run } from "as-test/assembly";
3
3
 
4
4
  describe("Should serialize booleans", () => {
5
- expect(JSON.stringify<bool>(true)).toBe("true");
5
+ expect(JSON.stringify<bool>(true)).toBe("true");
6
6
 
7
- expect(JSON.stringify<bool>(false)).toBe("false");
7
+ expect(JSON.stringify<bool>(false)).toBe("false");
8
8
 
9
- expect(JSON.stringify<boolean>(true)).toBe("true");
9
+ expect(JSON.stringify<boolean>(true)).toBe("true");
10
10
 
11
- expect(JSON.stringify<boolean>(false)).toBe("false");
11
+ expect(JSON.stringify<boolean>(false)).toBe("false");
12
12
  });
13
13
 
14
14
  describe("Should deserialize booleans", () => {
15
- expect(JSON.parse<boolean>("true")).toBe(true);
15
+ expect(JSON.parse<boolean>("true")).toBe(true);
16
16
 
17
- expect(JSON.parse<boolean>("false")).toBe(false);
17
+ expect(JSON.parse<boolean>("false")).toBe(false);
18
18
  });
19
19
 
20
- run();
20
+ run();
@@ -2,51 +2,51 @@ import { JSON } from "json-as";
2
2
  import { describe, expect, run } from "as-test/assembly";
3
3
 
4
4
  describe("Should serialize floats", () => {
5
- expect(JSON.stringify<f64>(7.23)).toBe("7.23");
5
+ expect(JSON.stringify<f64>(7.23)).toBe("7.23");
6
6
 
7
- expect(JSON.stringify<f64>(10e2)).toBe("1000.0");
7
+ expect(JSON.stringify<f64>(10e2)).toBe("1000.0");
8
8
 
9
- expect(JSON.stringify<f64>(123456e-5)).toBe("1.23456");
9
+ expect(JSON.stringify<f64>(123456e-5)).toBe("1.23456");
10
10
 
11
- expect(JSON.stringify<f64>(0.0)).toBe("0.0");
11
+ expect(JSON.stringify<f64>(0.0)).toBe("0.0");
12
12
 
13
- expect(JSON.stringify<f64>(-7.23)).toBe("-7.23");
13
+ expect(JSON.stringify<f64>(-7.23)).toBe("-7.23");
14
14
 
15
- expect(JSON.stringify<f64>(1e-6)).toBe("0.000001");
15
+ expect(JSON.stringify<f64>(1e-6)).toBe("0.000001");
16
16
 
17
- expect(JSON.stringify<f64>(1e-7)).toBe("1e-7");
17
+ expect(JSON.stringify<f64>(1e-7)).toBe("1e-7");
18
18
 
19
- expect(JSON.parse<f64>("1E-7")).toBe(1e-7);
19
+ expect(JSON.parse<f64>("1E-7")).toBe(1e-7);
20
20
 
21
- expect(JSON.stringify<f64>(1e20)).toBe("100000000000000000000.0");
21
+ expect(JSON.stringify<f64>(1e20)).toBe("100000000000000000000.0");
22
22
 
23
- expect(JSON.stringify<f64>(1e21)).toBe("1e+21");
23
+ expect(JSON.stringify<f64>(1e21)).toBe("1e+21");
24
24
 
25
- expect(JSON.parse<f64>("1E+21")).toBe(1e21);
25
+ expect(JSON.parse<f64>("1E+21")).toBe(1e21);
26
26
 
27
- expect(JSON.parse<f64>("1e21")).toBe(1e21);
27
+ expect(JSON.parse<f64>("1e21")).toBe(1e21);
28
28
 
29
- expect(JSON.parse<f64>("1E21")).toBe(1e21);
29
+ expect(JSON.parse<f64>("1E21")).toBe(1e21);
30
30
  });
31
31
 
32
32
  describe("Should deserialize floats", () => {
33
- expect(JSON.parse<f64>("7.23")).toBe(7.23);
33
+ expect(JSON.parse<f64>("7.23")).toBe(7.23);
34
34
 
35
- expect(JSON.parse<f64>("1000.0")).toBe(1000.0);
35
+ expect(JSON.parse<f64>("1000.0")).toBe(1000.0);
36
36
 
37
- expect(JSON.parse<f64>("1.23456")).toBe(1.23456);
37
+ expect(JSON.parse<f64>("1.23456")).toBe(1.23456);
38
38
 
39
- expect(JSON.parse<f64>("0.0")).toBe(0.0);
39
+ expect(JSON.parse<f64>("0.0")).toBe(0.0);
40
40
 
41
- expect(JSON.parse<f64>("-7.23")).toBe(-7.23);
41
+ expect(JSON.parse<f64>("-7.23")).toBe(-7.23);
42
42
 
43
- expect(JSON.parse<f64>("0.000001")).toBe(0.000001);
43
+ expect(JSON.parse<f64>("0.000001")).toBe(0.000001);
44
44
 
45
- expect(JSON.parse<f64>("1e-7")).toBe(1e-7);
45
+ expect(JSON.parse<f64>("1e-7")).toBe(1e-7);
46
46
 
47
- expect(JSON.parse<f64>("100000000000000000000.0")).toBe(1e20);
47
+ expect(JSON.parse<f64>("100000000000000000000.0")).toBe(1e20);
48
48
 
49
- expect(JSON.parse<f64>("1e+21")).toBe(1e21);
49
+ expect(JSON.parse<f64>("1e+21")).toBe(1e21);
50
50
  });
51
51
 
52
- run();
52
+ run();
@@ -2,27 +2,27 @@ import { JSON } from "json-as";
2
2
  import { describe, expect, run } from "as-test/assembly";
3
3
 
4
4
  describe("Should serialize integers", () => {
5
- expect(JSON.stringify(0)).toBe("0");
5
+ expect(JSON.stringify(0)).toBe("0");
6
6
 
7
- expect(JSON.stringify<u32>(100)).toBe("100");
7
+ expect(JSON.stringify<u32>(100)).toBe("100");
8
8
 
9
- expect(JSON.stringify<u64>(101)).toBe("101");
9
+ expect(JSON.stringify<u64>(101)).toBe("101");
10
10
 
11
- expect(JSON.stringify<i32>(-100)).toBe("-100");
11
+ expect(JSON.stringify<i32>(-100)).toBe("-100");
12
12
 
13
- expect(JSON.stringify<i64>(-101)).toBe("-101");
13
+ expect(JSON.stringify<i64>(-101)).toBe("-101");
14
14
  });
15
15
 
16
16
  describe("Should deserialize integers", () => {
17
- expect(JSON.parse<i32>("0")).toBe(<i32>0);
17
+ expect(JSON.parse<i32>("0")).toBe(<i32>0);
18
18
 
19
- expect(JSON.parse<u32>("100")).toBe(<u32>100);
19
+ expect(JSON.parse<u32>("100")).toBe(<u32>100);
20
20
 
21
- expect(JSON.parse<u64>("101")).toBe(<u64>101);
21
+ expect(JSON.parse<u64>("101")).toBe(<u64>101);
22
22
 
23
- expect(JSON.parse<i32>("-100")).toBe(<i32>-100);
23
+ expect(JSON.parse<i32>("-100")).toBe(<i32>-100);
24
24
 
25
- expect(JSON.parse<i64>("-101")).toBe(<i64>-101);
25
+ expect(JSON.parse<i64>("-101")).toBe(<i64>-101);
26
26
  });
27
27
 
28
- run();
28
+ run();
@@ -1,5 +1,4 @@
1
1
  import { JSON } from "json-as";
2
2
  import { describe, expect, run } from "as-test/assembly";
3
3
 
4
-
5
- run();
4
+ run();
@@ -2,47 +2,23 @@ import { JSON } from "json-as";
2
2
  import { describe, expect, run } from "as-test/assembly";
3
3
 
4
4
  describe("Should serialize strings", () => {
5
- expect(JSON.stringify("abcdefg")).toBe('"abcdefg"');
6
-
7
- expect(JSON.stringify('st"ring" w""ith quotes"')).toBe(
8
- '"st\\"ring\\" w\\"\\"ith quotes\\""',
9
- );
10
-
11
- expect(
12
- JSON.stringify('string "with random spa\nces and \nnewlines\n\n\n'),
13
- ).toBe('"string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"');
14
-
15
- expect(
16
- JSON.stringify(
17
- 'string with colon : comma , brace [ ] bracket { } and quote " and other quote \\"',
18
- ),
19
- ).toBe(
20
- '"string with colon : comma , brace [ ] bracket { } and quote \\" and other quote \\\\\\""',
21
- );
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 \\\\\\""');
22
12
  });
23
13
 
24
14
  describe("Should deserialize strings", () => {
25
- expect(JSON.parse<string>('"abcdefg"')).toBe("abcdefg");
26
-
27
- expect(
28
- JSON.parse<string>(
29
- '"\\"st\\\\\\"ring\\\\\\" w\\\\\\"\\\\\\"ith quotes\\\\\\"\\""',
30
- ),
31
- ).toBe('"st\\"ring\\" w\\"\\"ith quotes\\""');
32
-
33
- expect(
34
- JSON.parse<string>(
35
- '"\\"string \\\\\\"with random spa\\\\nces and \\\\nnewlines\\\\n\\\\n\\\\n\\""',
36
- ),
37
- ).toBe('"string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"');
38
-
39
- expect(
40
- JSON.parse<string>(
41
- '"\\"string with colon : comma , brace [ ] bracket { } and quote \\\\\\" and other quote \\\\\\\\\\"\\""',
42
- ),
43
- ).toBe(
44
- '"string with colon : comma , brace [ ] bracket { } and quote \\" and other quote \\\\""',
45
- );
46
- });
47
-
48
- run();
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,14 +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";
3
+ import { DerivedObject, Null, ObjWithStrangeKey, ObjectWithFloat, OmitIf, Player, Vec3 } from "./types";
12
4
 
13
5
  describe("Should serialize class inheritance", () => {
14
6
  const obj = new DerivedObject("1", "2");
@@ -25,23 +17,15 @@ describe("Should serialize integer arrays", () => {
25
17
 
26
18
  expect(JSON.stringify<u64[]>([0, 100, 101])).toBe("[0,100,101]");
27
19
 
28
- expect(JSON.stringify<i32[]>([0, 100, 101, -100, -101])).toBe(
29
- "[0,100,101,-100,-101]",
30
- );
20
+ expect(JSON.stringify<i32[]>([0, 100, 101, -100, -101])).toBe("[0,100,101,-100,-101]");
31
21
 
32
- expect(JSON.stringify<i64[]>([0, 100, 101, -100, -101])).toBe(
33
- "[0,100,101,-100,-101]",
34
- );
22
+ expect(JSON.stringify<i64[]>([0, 100, 101, -100, -101])).toBe("[0,100,101,-100,-101]");
35
23
  });
36
24
 
37
25
  describe("Should serialize float arrays", () => {
38
- expect(
39
- JSON.stringify<f64[]>([7.23, 10e2, 10e2, 123456e-5, 123456e-5, 0.0, 7.23]),
40
- ).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]");
41
27
 
42
- expect(JSON.stringify<f64[]>([1e21, 1e22, 1e-7, 1e-8, 1e-9])).toBe(
43
- "[1e+21,1e+22,1e-7,1e-8,1e-9]",
44
- );
28
+ expect(JSON.stringify<f64[]>([1e21, 1e22, 1e-7, 1e-8, 1e-9])).toBe("[1e+21,1e+22,1e-7,1e-8,1e-9]");
45
29
  });
46
30
 
47
31
  describe("Should serialize boolean arrays", () => {
@@ -51,39 +35,21 @@ describe("Should serialize boolean arrays", () => {
51
35
  });
52
36
 
53
37
  describe("Should serialize string arrays", () => {
54
- expect(
55
- JSON.stringify<string[]>([
56
- 'string "with random spa\nces and \nnewlines\n\n\n',
57
- ]),
58
- ).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"]');
59
39
  });
60
40
 
61
41
  describe("Should serialize nested integer arrays", () => {
62
- expect(JSON.stringify<i64[][]>([[100, 101], [-100, -101], [0]])).toBe(
63
- "[[100,101],[-100,-101],[0]]",
64
- );
42
+ expect(JSON.stringify<i64[][]>([[100, 101], [-100, -101], [0]])).toBe("[[100,101],[-100,-101],[0]]");
65
43
  });
66
44
 
67
45
  describe("Should serialize nested float arrays", () => {
68
- expect(
69
- JSON.stringify<f64[][]>([
70
- [7.23],
71
- [10e2],
72
- [10e2],
73
- [123456e-5],
74
- [123456e-5],
75
- [0.0],
76
- [7.23],
77
- ]),
78
- ).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]]");
79
47
  });
80
48
 
81
49
  describe("Should serialize nested boolean arrays", () => {
82
50
  expect(JSON.stringify<bool[][]>([[true], [false]])).toBe("[[true],[false]]");
83
51
 
84
- expect(JSON.stringify<boolean[][]>([[true], [false]])).toBe(
85
- "[[true],[false]]",
86
- );
52
+ expect(JSON.stringify<boolean[][]>([[true], [false]])).toBe("[[true],[false]]");
87
53
  });
88
54
 
89
55
  describe("Should serialize object arrays", () => {
@@ -125,27 +91,19 @@ describe("Should serialize objects", () => {
125
91
  },
126
92
  isVerified: true,
127
93
  }),
128
- ).toBe(
129
- '{"firstName":"Emmet","lastName":"West","lastActive":[8,27,2022],"age":23,"pos":{"x":3.4,"y":1.2,"z":8.3},"isVerified":true}',
130
- );
94
+ ).toBe('{"firstName":"Emmet","lastName":"West","lastActive":[8,27,2022],"age":23,"pos":{"x":3.4,"y":1.2,"z":8.3},"isVerified":true}');
131
95
 
132
96
  expect(JSON.stringify<ObjectWithFloat>({ f: 7.23 })).toBe('{"f":7.23}');
133
97
 
134
- expect(JSON.stringify<ObjectWithFloat>({ f: 0.000001 })).toBe(
135
- '{"f":0.000001}',
136
- );
98
+ expect(JSON.stringify<ObjectWithFloat>({ f: 0.000001 })).toBe('{"f":0.000001}');
137
99
 
138
100
  expect(JSON.stringify<ObjectWithFloat>({ f: 1e-7 })).toBe('{"f":1e-7}');
139
101
 
140
- expect(JSON.stringify<ObjectWithFloat>({ f: 1e20 })).toBe(
141
- '{"f":100000000000000000000.0}',
142
- );
102
+ expect(JSON.stringify<ObjectWithFloat>({ f: 1e20 })).toBe('{"f":100000000000000000000.0}');
143
103
 
144
104
  expect(JSON.stringify<ObjectWithFloat>({ f: 1e21 })).toBe('{"f":1e+21}');
145
105
 
146
- expect(JSON.stringify<ObjWithStrangeKey<string>>({ data: "foo" })).toBe(
147
- '{"a\\\\\\t\\"\\u0002b`c":"foo"}',
148
- );
106
+ expect(JSON.stringify<ObjWithStrangeKey<string>>({ data: "foo" })).toBe('{"a\\\\\\t\\"\\u0002b`c":"foo"}');
149
107
  });
150
108
 
151
109
  describe("Should serialize @omit'ed objects", () => {
@@ -169,83 +127,39 @@ describe("Should deserialize nulls", () => {
169
127
  });
170
128
 
171
129
  describe("Should deserialize integer arrays", () => {
172
- expect(JSON.stringify(JSON.parse<u32[]>("[0,100,101]"))).toBe(
173
- JSON.stringify([0, 100, 101]),
174
- );
130
+ expect(JSON.stringify(JSON.parse<u32[]>("[0,100,101]"))).toBe(JSON.stringify([0, 100, 101]));
175
131
 
176
- expect(JSON.stringify(JSON.parse<i32[]>("[0,100,101,-100,-101]"))).toBe(
177
- JSON.stringify([0, 100, 101, -100, -101]),
178
- );
132
+ expect(JSON.stringify(JSON.parse<i32[]>("[0,100,101,-100,-101]"))).toBe(JSON.stringify([0, 100, 101, -100, -101]));
179
133
  });
180
134
 
181
135
  describe("Should deserialize float arrays", () => {
182
- expect(
183
- JSON.stringify(
184
- JSON.parse<f64[]>("[7.23,1000.0,1000.0,1.23456,1.23456,0.0,7.23]"),
185
- ),
186
- ).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]));
187
137
 
188
- expect(
189
- JSON.stringify(JSON.parse<f64[]>("[1e+21,1e+22,1e-7,1e-8,1e-9]")),
190
- ).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]));
191
139
  });
192
140
 
193
141
  describe("Should deserialize boolean arrays", () => {
194
- expect(JSON.stringify(JSON.parse<boolean[]>("[true,false]"))).toBe(
195
- JSON.stringify([true, false]),
196
- );
142
+ expect(JSON.stringify(JSON.parse<boolean[]>("[true,false]"))).toBe(JSON.stringify([true, false]));
197
143
  });
198
144
 
199
145
  describe("Should deserialize string arrays", () => {
200
- expect(
201
- JSON.stringify(
202
- JSON.parse<string[]>(
203
- '["string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"]',
204
- ),
205
- ),
206
- ).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']));
207
147
  });
208
148
 
209
149
  describe("Should deserialize nested integer arrays", () => {
210
- expect(
211
- JSON.stringify(JSON.parse<i64[][]>("[[100,101],[-100,-101],[0]]")),
212
- ).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]]));
213
151
  });
214
152
 
215
153
  describe("Should deserialize nested float arrays", () => {
216
- expect(
217
- JSON.stringify(
218
- JSON.parse<f64[][]>(
219
- "[[7.23],[1000.0],[1000.0],[1.23456],[1.23456],[0.0],[7.23]]",
220
- ),
221
- ),
222
- ).toBe(
223
- JSON.stringify([
224
- [7.23],
225
- [1000.0],
226
- [1000.0],
227
- [1.23456],
228
- [1.23456],
229
- [0.0],
230
- [7.23],
231
- ]),
232
- );
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]]));
233
155
  });
234
156
 
235
157
  describe("Should deserialize nested boolean arrays", () => {
236
- expect(JSON.stringify(JSON.parse<boolean[][]>("[[true],[false]]"))).toBe(
237
- JSON.stringify([[true], [false]]),
238
- );
158
+ expect(JSON.stringify(JSON.parse<boolean[][]>("[[true],[false]]"))).toBe(JSON.stringify([[true], [false]]));
239
159
  });
240
160
 
241
161
  describe("Should deserialize object arrays", () => {
242
- expect(
243
- JSON.stringify(
244
- JSON.parse<Vec3[]>(
245
- '[{"x":3.4,"y":1.2,"z":8.3},{"x":3.4,"y":-2.1,"z":9.3}]',
246
- ),
247
- ),
248
- ).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(
249
163
  JSON.stringify(<Vec3[]>[
250
164
  { x: 3.4, y: 1.2, z: 8.3 },
251
165
  { x: 3.4, y: -2.1, z: 9.3 },
@@ -254,17 +168,9 @@ describe("Should deserialize object arrays", () => {
254
168
  });
255
169
 
256
170
  describe("Should deserialize Objects", () => {
257
- expect(JSON.stringify(JSON.parse<Vec3>('{"x":3.4,"y":1.2,"z":8.3}'))).toBe(
258
- JSON.stringify(<Vec3>{ x: 3.4, y: 1.2, z: 8.3 }),
259
- );
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 }));
260
172
 
261
- expect(
262
- JSON.stringify(
263
- JSON.parse<Player>(
264
- '{"firstName":"Emmet","lastName":"West","lastActive":[8,27,2022],"age":23,"pos":{"x":3.4,"y":1.2,"z":8.3},"isVerified":true}',
265
- ),
266
- ),
267
- ).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(
268
174
  JSON.stringify(<Player>{
269
175
  firstName: "Emmet",
270
176
  lastName: "West",
@@ -275,19 +181,11 @@ describe("Should deserialize Objects", () => {
275
181
  }),
276
182
  );
277
183
 
278
- expect(JSON.stringify(JSON.parse<ObjectWithFloat>('{"f":7.23}'))).toBe(
279
- JSON.stringify(<ObjectWithFloat>{ f: 7.23 }),
280
- );
184
+ expect(JSON.stringify(JSON.parse<ObjectWithFloat>('{"f":7.23}'))).toBe(JSON.stringify(<ObjectWithFloat>{ f: 7.23 }));
281
185
 
282
- expect(JSON.stringify(JSON.parse<ObjectWithFloat>('{"f":0.000001}'))).toBe(
283
- JSON.stringify(<ObjectWithFloat>{ f: 0.000001 }),
284
- );
186
+ expect(JSON.stringify(JSON.parse<ObjectWithFloat>('{"f":0.000001}'))).toBe(JSON.stringify(<ObjectWithFloat>{ f: 0.000001 }));
285
187
 
286
- expect(
287
- JSON.stringify(
288
- JSON.parse<ObjWithStrangeKey<string>>('{"a\\\\\\t\\"\\u0002b`c":"foo"}'),
289
- ),
290
- ).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" }));
291
189
  });
292
190
 
293
191
  run({