json-as 0.4.2 → 0.4.5
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/LICENSE +0 -0
- package/README.md +39 -5
- package/as-pect.asconfig.json +24 -0
- package/as-pect.config.js +30 -0
- package/asconfig.json +1 -16
- package/assembly/__benches__/as-tral.d.ts +0 -0
- package/assembly/__benches__/benchmark.ts +35 -30
- package/assembly/__tests__/as-json.spec.ts +0 -0
- package/assembly/__tests__/as-pect.d.ts +1 -0
- package/assembly/chars.ts +2 -1
- package/assembly/index.ts +305 -190
- package/assembly/test.ts +67 -17
- package/assembly/tsconfig.json +0 -0
- package/assembly/util.ts +30 -0
- package/index.ts +0 -1
- package/package.json +7 -6
- package/tests/index.js +0 -0
- package/tests/test.js +0 -0
- package/transform/lib/index.js +74 -78
- package/transform/package.json +1 -2
- package/transform/src/index.old.js +0 -0
- package/transform/src/index.ts +109 -98
- package/transform/tsconfig.json +1 -1
package/assembly/test.ts
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
import "wasi";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
JSON,
|
|
4
|
+
parseArrayArray,
|
|
5
|
+
parseNumberArray,
|
|
6
|
+
parseObject,
|
|
7
|
+
parseObjectArray,
|
|
8
|
+
} from ".";
|
|
9
|
+
import { removeWhitespace } from "./util";
|
|
3
10
|
|
|
11
|
+
// @ts-ignore
|
|
4
12
|
@json
|
|
5
13
|
class Vec2 {
|
|
6
|
-
x: f32
|
|
7
|
-
y: f32
|
|
14
|
+
x: f32;
|
|
15
|
+
y: f32;
|
|
8
16
|
}
|
|
17
|
+
|
|
18
|
+
// @ts-ignore
|
|
9
19
|
@json
|
|
10
20
|
class Player {
|
|
11
|
-
firstName: string
|
|
12
|
-
lastName: string
|
|
13
|
-
lastActive: i32[]
|
|
14
|
-
age: i32
|
|
15
|
-
pos: Vec2
|
|
21
|
+
firstName: string;
|
|
22
|
+
lastName: string;
|
|
23
|
+
lastActive: i32[];
|
|
24
|
+
age: i32;
|
|
25
|
+
pos: Vec2;
|
|
26
|
+
isVerified: boolean;
|
|
16
27
|
}
|
|
17
28
|
|
|
18
29
|
const data: Player = {
|
|
@@ -22,14 +33,53 @@ const data: Player = {
|
|
|
22
33
|
age: 23,
|
|
23
34
|
pos: {
|
|
24
35
|
x: -3.4,
|
|
25
|
-
y: 1.2
|
|
26
|
-
}
|
|
27
|
-
|
|
36
|
+
y: 1.2,
|
|
37
|
+
},
|
|
38
|
+
isVerified: true,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const serialized = JSON.stringify<Player>(data);
|
|
42
|
+
console.log("Serialized: " + serialized);
|
|
43
|
+
const deserialized = JSON.parse<Player>(serialized);
|
|
44
|
+
console.log("Deserialized: " + JSON.stringify(deserialized));
|
|
45
|
+
/*
|
|
46
|
+
const parsed = JSON.parse<Player>(stringified);
|
|
47
|
+
console.log("Vec2 Parse: " + JSON.stringify<Player>(parsed));
|
|
48
|
+
console.log(
|
|
49
|
+
`Parsed String Array: ${JSON.stringify(
|
|
50
|
+
JSON.parse<string[]>(`\n[ "hello" , "world" ] `)
|
|
51
|
+
)}`
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
console.log(
|
|
55
|
+
`Parsed Boolean Array: ${JSON.stringify(
|
|
56
|
+
JSON.parse<boolean[]>(`\n[ false , true ] `)
|
|
57
|
+
)}`
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
console.log(
|
|
61
|
+
`Parsed Number Array: ${JSON.stringify(
|
|
62
|
+
JSON.parse<i32[]>(`[ 1 , 2\n ,3\n\t ]`)
|
|
63
|
+
)}`
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
console.log(
|
|
67
|
+
JSON.stringify<Vec2>(
|
|
68
|
+
load<Vec2>(changetype<usize>(data), offsetof<Player>("pos"))
|
|
69
|
+
)
|
|
70
|
+
);
|
|
28
71
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
72
|
+
console.log(
|
|
73
|
+
JSON.stringify<string[][]>(
|
|
74
|
+
parseArrayArray<string[][]>('[["a","b","c"],["d","e","f"]]')
|
|
75
|
+
)
|
|
76
|
+
);
|
|
32
77
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
78
|
+
console.log(
|
|
79
|
+
JSON.stringify<Player[][]>(
|
|
80
|
+
parseObjectArray<Player[][]>(
|
|
81
|
+
'[{"firstName":"Emmet","lastName":"West","lastActive":[8,7],"age":23,"pos":{"x":-3.4000000953674318,"y":1.2000000476837159}}]'
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
*/
|
package/assembly/tsconfig.json
CHANGED
|
File without changes
|
package/assembly/util.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { StringSink } from "as-string-sink/assembly";
|
|
2
|
+
import { isSpace } from "assemblyscript/std/assembly/util/string";
|
|
3
|
+
import { backSlashCode, quoteCode } from "./chars";
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
@inline
|
|
6
|
+
export function unsafeCharCodeAt(data: string, pos: i32): i32 {
|
|
7
|
+
return load<u16>(changetype<usize>(data) + ((<usize>pos) << 1));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function removeWhitespace(data: string): string {
|
|
11
|
+
const result = new StringSink();
|
|
12
|
+
let instr = false;
|
|
13
|
+
for (let i = 0; i < data.length; i++) {
|
|
14
|
+
const char = data.charCodeAt(i);
|
|
15
|
+
if (instr === false && char === quoteCode) instr = true;
|
|
16
|
+
else if (
|
|
17
|
+
instr === true &&
|
|
18
|
+
char === quoteCode &&
|
|
19
|
+
data.charCodeAt(i - 1) !== backSlashCode
|
|
20
|
+
)
|
|
21
|
+
instr = false;
|
|
22
|
+
|
|
23
|
+
if (instr === false) {
|
|
24
|
+
if (!isSpace(char)) result.write(data.charAt(i));
|
|
25
|
+
} else {
|
|
26
|
+
result.write(data.charAt(i));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return result.toString();
|
|
30
|
+
}
|
package/index.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { JSON } from "./assembly/index";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-as",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "JSON encoder/decoder for AssemblyScript",
|
|
5
5
|
"types": "assembly/index.ts",
|
|
6
6
|
"author": "Jairus Tanaka",
|
|
@@ -14,20 +14,20 @@
|
|
|
14
14
|
"build:transform": "tsc -p ./transform",
|
|
15
15
|
"test:wasmtime": "wasmtime ./build/test.wasm",
|
|
16
16
|
"test:lunatic": "lunatic ./build/test.wasm",
|
|
17
|
-
"test:wasm3": "wasm3 ./build/test.wasm"
|
|
17
|
+
"test:wasm3": "wasm3 ./build/test.wasm",
|
|
18
|
+
"prettier": "as-prettier -w ."
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
21
|
+
"@as-pect/cli": "^7.0.7",
|
|
20
22
|
"@as-tral/cli": "^1.1.1",
|
|
21
23
|
"as-console": "^6.0.2",
|
|
22
24
|
"assemblyscript": "^0.20.7",
|
|
23
25
|
"assemblyscript-prettier": "^1.0.2",
|
|
24
|
-
"benchmark": "^2.1.4",
|
|
25
|
-
"microtime": "^3.0.0",
|
|
26
26
|
"typescript": "^4.7.2"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"as-string-sink": "^0.5.0",
|
|
30
|
-
"as-variant": "^0.
|
|
30
|
+
"as-variant": "^0.4.0"
|
|
31
31
|
},
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"json",
|
|
39
39
|
"serialize",
|
|
40
40
|
"deserialize",
|
|
41
|
-
"dynamic"
|
|
41
|
+
"dynamic",
|
|
42
|
+
"serde"
|
|
42
43
|
],
|
|
43
44
|
"bugs": {
|
|
44
45
|
"url": "https://github.com/JairusSW/as-json/issues"
|
package/tests/index.js
CHANGED
|
File without changes
|
package/tests/test.js
CHANGED
|
File without changes
|
package/transform/lib/index.js
CHANGED
|
@@ -1,78 +1,74 @@
|
|
|
1
|
-
import { ClassDecorator, registerDecorator } from "visitor-as/dist/decorator.js";
|
|
2
|
-
import { getName } from "visitor-as/dist/utils.js";
|
|
3
|
-
import { SimpleParser } from "visitor-as/dist/index.js";
|
|
4
|
-
class AsJSONTransform extends ClassDecorator {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(...arguments);
|
|
7
|
-
this.sources = [];
|
|
8
|
-
this.encodeStmts =
|
|
9
|
-
this.
|
|
10
|
-
}
|
|
11
|
-
visitMethodDeclaration(node) { }
|
|
12
|
-
visitFieldDeclaration(node) {
|
|
13
|
-
const name = getName(node);
|
|
14
|
-
if (!node.type) {
|
|
15
|
-
throw new Error(`Field ${name} is missing a type declaration`);
|
|
16
|
-
}
|
|
17
|
-
const type = getName(node.type);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
node.members.push(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return "json";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
export default registerDecorator(new AsJSONTransform());
|
|
1
|
+
import { ClassDecorator, registerDecorator, } from "visitor-as/dist/decorator.js";
|
|
2
|
+
import { getName } from "visitor-as/dist/utils.js";
|
|
3
|
+
import { SimpleParser } from "visitor-as/dist/index.js";
|
|
4
|
+
class AsJSONTransform extends ClassDecorator {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.sources = [];
|
|
8
|
+
this.encodeStmts = [];
|
|
9
|
+
this.decodeStmts = [];
|
|
10
|
+
}
|
|
11
|
+
visitMethodDeclaration(node) { }
|
|
12
|
+
visitFieldDeclaration(node) {
|
|
13
|
+
const name = getName(node);
|
|
14
|
+
if (!node.type) {
|
|
15
|
+
throw new Error(`Field ${name} is missing a type declaration`);
|
|
16
|
+
}
|
|
17
|
+
const type = getName(node.type);
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
this.encodeStmts.push(`"${name}":\${JSON.stringify<${type}>(this.${name})},`);
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
this.decodeStmts.push(`${name}: JSON.parse<${type}>(values.get("${name}")),\n`);
|
|
22
|
+
}
|
|
23
|
+
visitClassDeclaration(node) {
|
|
24
|
+
if (!node.members) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.currentClass = node;
|
|
28
|
+
const name = getName(node);
|
|
29
|
+
this.visit(node.members);
|
|
30
|
+
const serializedProp = `__JSON_Serialized: string = "";`;
|
|
31
|
+
let serializeFunc = ``;
|
|
32
|
+
if (this.encodeStmts.length > 0) {
|
|
33
|
+
const stmt = this.encodeStmts[this.encodeStmts.length - 1];
|
|
34
|
+
this.encodeStmts[this.encodeStmts.length - 1] = stmt.slice(0, stmt.length - 1);
|
|
35
|
+
serializeFunc = `
|
|
36
|
+
@inline
|
|
37
|
+
__JSON_Serialize(): string {
|
|
38
|
+
return \`{${this.encodeStmts.join("")}}\`;
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
serializeFunc = `
|
|
44
|
+
@inline
|
|
45
|
+
__JSON_Serialize(): string {
|
|
46
|
+
return "{}";
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
const deserializeFunc = `
|
|
51
|
+
@inline
|
|
52
|
+
__JSON_Deserialize(values: Map<string, string>): ${name} {
|
|
53
|
+
return {
|
|
54
|
+
${
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
this.decodeStmts.join("")}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
this.encodeStmts = [];
|
|
61
|
+
this.decodeStmts = [];
|
|
62
|
+
//console.log(serializeFunc, deserializeFunc)
|
|
63
|
+
const serializedProperty = SimpleParser.parseClassMember(serializedProp, node);
|
|
64
|
+
node.members.push(serializedProperty);
|
|
65
|
+
const serializeMethod = SimpleParser.parseClassMember(serializeFunc, node);
|
|
66
|
+
node.members.push(serializeMethod);
|
|
67
|
+
const deserializeMethod = SimpleParser.parseClassMember(deserializeFunc, node);
|
|
68
|
+
node.members.push(deserializeMethod);
|
|
69
|
+
}
|
|
70
|
+
get name() {
|
|
71
|
+
return "json";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export default registerDecorator(new AsJSONTransform());
|
package/transform/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@json-as/transform",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "JSON encoder/decoder for AssemblyScript",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"author": "Jairus Tanaka",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"DogWhich"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"scripts": {},
|
|
12
11
|
"devDependencies": {},
|
|
13
12
|
"dependencies": {
|
|
14
13
|
"visitor-as": "^0.10.2"
|
|
File without changes
|
package/transform/src/index.ts
CHANGED
|
@@ -1,98 +1,109 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "assemblyscript/dist/assemblyscript";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
__JSON_Serialize(): string {
|
|
70
|
-
return "{}";
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
1
|
+
import {
|
|
2
|
+
ClassDeclaration,
|
|
3
|
+
FieldDeclaration,
|
|
4
|
+
MethodDeclaration,
|
|
5
|
+
Source,
|
|
6
|
+
} from "assemblyscript/dist/assemblyscript";
|
|
7
|
+
import {
|
|
8
|
+
ClassDecorator,
|
|
9
|
+
registerDecorator,
|
|
10
|
+
} from "visitor-as/dist/decorator.js";
|
|
11
|
+
import { getName } from "visitor-as/dist/utils.js";
|
|
12
|
+
import { SimpleParser } from "visitor-as/dist/index.js";
|
|
13
|
+
|
|
14
|
+
class AsJSONTransform extends ClassDecorator {
|
|
15
|
+
public currentClass!: ClassDeclaration;
|
|
16
|
+
public sources: Source[] = [];
|
|
17
|
+
public encodeStmts: string[] = [];
|
|
18
|
+
public decodeStmts: string[] = [];
|
|
19
|
+
|
|
20
|
+
visitMethodDeclaration(node: MethodDeclaration): void {}
|
|
21
|
+
visitFieldDeclaration(node: FieldDeclaration): void {
|
|
22
|
+
const name = getName(node);
|
|
23
|
+
if (!node.type) {
|
|
24
|
+
throw new Error(`Field ${name} is missing a type declaration`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const type = getName(node.type);
|
|
28
|
+
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
this.encodeStmts.push(
|
|
31
|
+
`"${name}":\${JSON.stringify<${type}>(this.${name})},`
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
this.decodeStmts.push(
|
|
36
|
+
`${name}: JSON.parse<${type}>(values.get("${name}")),\n`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
visitClassDeclaration(node: ClassDeclaration): void {
|
|
40
|
+
if (!node.members) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this.currentClass = node;
|
|
45
|
+
|
|
46
|
+
const name = getName(node);
|
|
47
|
+
|
|
48
|
+
this.visit(node.members);
|
|
49
|
+
|
|
50
|
+
const serializedProp = `__JSON_Serialized: string = "";`;
|
|
51
|
+
|
|
52
|
+
let serializeFunc = ``;
|
|
53
|
+
|
|
54
|
+
if (this.encodeStmts.length > 0) {
|
|
55
|
+
const stmt = this.encodeStmts[this.encodeStmts.length - 1]!;
|
|
56
|
+
this.encodeStmts[this.encodeStmts.length - 1] = stmt!.slice(
|
|
57
|
+
0,
|
|
58
|
+
stmt.length - 1
|
|
59
|
+
);
|
|
60
|
+
serializeFunc = `
|
|
61
|
+
@inline
|
|
62
|
+
__JSON_Serialize(): string {
|
|
63
|
+
return \`{${this.encodeStmts.join("")}}\`;
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
} else {
|
|
67
|
+
serializeFunc = `
|
|
68
|
+
@inline
|
|
69
|
+
__JSON_Serialize(): string {
|
|
70
|
+
return "{}";
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const deserializeFunc = `
|
|
76
|
+
@inline
|
|
77
|
+
__JSON_Deserialize(values: Map<string, string>): ${name} {
|
|
78
|
+
return {
|
|
79
|
+
${
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
this.decodeStmts.join("")
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
this.encodeStmts = [];
|
|
87
|
+
this.decodeStmts = [];
|
|
88
|
+
//console.log(serializeFunc, deserializeFunc)
|
|
89
|
+
const serializedProperty = SimpleParser.parseClassMember(
|
|
90
|
+
serializedProp,
|
|
91
|
+
node
|
|
92
|
+
);
|
|
93
|
+
node.members.push(serializedProperty);
|
|
94
|
+
|
|
95
|
+
const serializeMethod = SimpleParser.parseClassMember(serializeFunc, node);
|
|
96
|
+
node.members.push(serializeMethod);
|
|
97
|
+
|
|
98
|
+
const deserializeMethod = SimpleParser.parseClassMember(
|
|
99
|
+
deserializeFunc,
|
|
100
|
+
node
|
|
101
|
+
);
|
|
102
|
+
node.members.push(deserializeMethod);
|
|
103
|
+
}
|
|
104
|
+
get name(): string {
|
|
105
|
+
return "json";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default registerDecorator(new AsJSONTransform());
|
package/transform/tsconfig.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
15
15
|
"sourceMap": false /* Generates corresponding '.map' file. */,
|
|
16
16
|
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
|
-
"outDir": "./lib
|
|
17
|
+
"outDir": "./lib" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
|
18
18
|
// "composite": true, /* Enable project compilation */
|
|
19
19
|
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
20
20
|
// "removeComments": true, /* Do not emit comments to output. */
|