json-as 0.9.3 → 0.9.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.
- package/CHANGELOG +2 -0
- package/README.md +1 -1
- package/assembly/serialize/unknown.ts +45 -0
- package/package.json +1 -1
- package/transform/package.json +1 -1
package/CHANGELOG
CHANGED
|
@@ -7,5 +7,7 @@ v0.8.6 - Fix. Forgot to stash before publishing. Stash and push what should have
|
|
|
7
7
|
v0.9.0 - BREAKING CHANGE - API changed from JSON.parse(data, defaultValues) to JSON.parse(data). Default Values defaults to true. Large update. Refactor all the code, nullable primitives, rewrite the transform, allow extensibility with @omit keywords, and fix a plethora of bugs
|
|
8
8
|
v0.9.1 - Fix #71
|
|
9
9
|
v0.9.2 - Fix #75 + Build sizes significantly reduced
|
|
10
|
+
v0.9.3 - Fix #76
|
|
11
|
+
v0.9.4 - Fix #77
|
|
10
12
|
|
|
11
13
|
[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
|
@@ -0,0 +1,45 @@
|
|
|
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): string {
|
|
17
|
+
const type = data.type;
|
|
18
|
+
switch (type) {
|
|
19
|
+
case JSON.Types.String: {
|
|
20
|
+
return serializeString(data.get<string>());
|
|
21
|
+
}
|
|
22
|
+
case JSON.Types.Bool: {
|
|
23
|
+
return serializeBool(data.get<bool>());
|
|
24
|
+
}
|
|
25
|
+
case JSON.Types.U8: {
|
|
26
|
+
return serializeInteger(data.get<u8>());
|
|
27
|
+
}
|
|
28
|
+
case JSON.Types.U16: {
|
|
29
|
+
return serializeInteger(data.get<u16>());
|
|
30
|
+
}
|
|
31
|
+
case JSON.Types.U32: {
|
|
32
|
+
return serializeInteger(data.get<u32>());
|
|
33
|
+
}
|
|
34
|
+
case JSON.Types.U64: {
|
|
35
|
+
return serializeInteger(data.get<u64>());
|
|
36
|
+
}
|
|
37
|
+
case JSON.Types.F32: {
|
|
38
|
+
return serializeFloat(data.get<f32>());
|
|
39
|
+
}
|
|
40
|
+
case JSON.Types.F64: {
|
|
41
|
+
return serializeFloat(data.get<f64>());
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return serializeUnknownArray(data.get<JSON.Value[]>());
|
|
45
|
+
}
|
package/package.json
CHANGED