json-as 0.9.6 → 0.9.7
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/.github/workflows/release-package.yml +1 -1
- package/CHANGELOG +2 -0
- package/README.md +9 -11
- package/assembly/__tests__/deserialize.spec.ts +4 -1
- package/assembly/__tests__/serialize.spec.ts +4 -1
- package/develop/assembly/serialize/unknown.ts +46 -0
- package/package.json +2 -2
- package/transform/package.json +1 -1
package/CHANGELOG
CHANGED
|
@@ -10,5 +10,7 @@ v0.9.2 - Fix #75 + Build sizes significantly reduced
|
|
|
10
10
|
v0.9.3 - Fix #76
|
|
11
11
|
v0.9.4 - Fix #77
|
|
12
12
|
v0.9.5 - Fix #46
|
|
13
|
+
v0.9.6 - Fix bugs
|
|
14
|
+
v0.9.7 - Update testing framework and readme logo
|
|
13
15
|
|
|
14
16
|
[UNRELEASED] v0.9.x - Port JSON.Value from the `develop` branch to allow for union types, parsing of arbitrary data, and whatever the hell you want.
|
package/README.md
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
<
|
|
2
|
-
<pre>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
v0.9.6
|
|
1
|
+
<h5 align="center">
|
|
2
|
+
<pre>
|
|
3
|
+
_____ _____ __ _____ _____ _____
|
|
4
|
+
| _ | __|___ __| | __| | | |
|
|
5
|
+
| |__ |___| | |__ | | | | | |
|
|
6
|
+
|__|__|_____| |_____|_____|_____|_|___|
|
|
7
|
+
|
|
8
|
+
v0.9.7
|
|
11
9
|
</pre>
|
|
12
|
-
</
|
|
10
|
+
</h5>
|
|
13
11
|
|
|
14
12
|
## Installation
|
|
15
13
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { JSON } from "..";
|
|
2
2
|
import {
|
|
3
3
|
describe,
|
|
4
|
-
expect
|
|
4
|
+
expect,
|
|
5
|
+
run
|
|
5
6
|
} from "as-test/assembly";
|
|
6
7
|
|
|
7
8
|
@json
|
|
@@ -271,6 +272,8 @@ describe("Should deserialize Objects", () => {
|
|
|
271
272
|
|
|
272
273
|
});
|
|
273
274
|
|
|
275
|
+
run();
|
|
276
|
+
|
|
274
277
|
@json
|
|
275
278
|
class ObjWithString {
|
|
276
279
|
s!: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { JSON } from "..";
|
|
2
2
|
import {
|
|
3
3
|
describe,
|
|
4
|
-
expect
|
|
4
|
+
expect,
|
|
5
|
+
run
|
|
5
6
|
} from "as-test/assembly";
|
|
6
7
|
|
|
7
8
|
@json
|
|
@@ -368,6 +369,8 @@ describe("Should serialize @omit'ed objects", () => {
|
|
|
368
369
|
|
|
369
370
|
});
|
|
370
371
|
|
|
372
|
+
run();
|
|
373
|
+
|
|
371
374
|
@json
|
|
372
375
|
class ObjWithString {
|
|
373
376
|
s!: string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { JSON } from "..";
|
|
2
|
+
import { Sink } from "../src/sink";
|
|
3
|
+
import { __atoi_fast } from "../src/util";
|
|
4
|
+
import { serializeUnknownArray } from "./array/unknown";
|
|
5
|
+
import { serializeBool } from "./bool";
|
|
6
|
+
import { serializeFloat } from "./float";
|
|
7
|
+
import { serializeInteger } from "./integer";
|
|
8
|
+
import { serializeString } from "./string";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Serializes unknown values into their correct serializer and returns the data.
|
|
12
|
+
*
|
|
13
|
+
* @param data - The JSON.Value to be serialized.
|
|
14
|
+
* @returns The serialized result.
|
|
15
|
+
*/
|
|
16
|
+
export function serializeUnknown(data: JSON.Value, out: Sink | null = null): Sink {
|
|
17
|
+
const type = data.type;
|
|
18
|
+
switch (type) {
|
|
19
|
+
case JSON.Types.String: {
|
|
20
|
+
return serializeString(data.get<string>(), out);
|
|
21
|
+
}
|
|
22
|
+
case JSON.Types.Boolean: {
|
|
23
|
+
return serializeBool(data.get<bool>(), out);
|
|
24
|
+
}
|
|
25
|
+
case JSON.Types.U8: {
|
|
26
|
+
return serializeInteger(data.get<u8>(), out);
|
|
27
|
+
}
|
|
28
|
+
case JSON.Types.U16: {
|
|
29
|
+
return serializeInteger(data.get<u16>(), out);
|
|
30
|
+
}
|
|
31
|
+
case JSON.Types.U32: {
|
|
32
|
+
return serializeInteger(data.get<u32>(), out);
|
|
33
|
+
}
|
|
34
|
+
case JSON.Types.U64: {
|
|
35
|
+
return serializeInteger(data.get<u64>(), out);
|
|
36
|
+
}
|
|
37
|
+
case JSON.Types.F32: {
|
|
38
|
+
return serializeFloat(data.get<f32>(), out);
|
|
39
|
+
}
|
|
40
|
+
case JSON.Types.F64: {
|
|
41
|
+
return serializeFloat(data.get<f64>(), out);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return serializeUnknownArray(data.get<JSON.Value[]>(), out);
|
|
45
|
+
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-as",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7",
|
|
4
4
|
"description": "JSON encoder/decoder for AssemblyScript",
|
|
5
5
|
"types": "assembly/index.ts",
|
|
6
6
|
"author": "Jairus Tanaka",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@assemblyscript/wasi-shim": "^0.1.0",
|
|
35
35
|
"as-bench": "^0.0.0-alpha",
|
|
36
|
-
"as-test": "JairusSW/as-test",
|
|
37
36
|
"assemblyscript": "^0.27.22",
|
|
38
37
|
"assemblyscript-prettier": "^3.0.1",
|
|
39
38
|
"benchmark": "^2.1.4",
|
|
@@ -46,6 +45,7 @@
|
|
|
46
45
|
"dependencies": {
|
|
47
46
|
"as-container": "^0.8.0",
|
|
48
47
|
"as-string-sink": "^0.5.3",
|
|
48
|
+
"as-test": "^0.0.2",
|
|
49
49
|
"as-variant": "^0.4.1",
|
|
50
50
|
"as-virtual": "^0.2.0"
|
|
51
51
|
},
|