json-as 1.1.15-preview.5 → 1.1.16
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.md +7 -2
- package/README.md +1 -10
- package/assembly/test.tmp.ts +599 -55
- package/assembly/test.ts +36 -57
- package/package.json +3 -2
- package/transform/lib/index.js +25 -28
- package/transform/lib/index.js.map +1 -1
- package/transform/src/index.ts +32 -25
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2025-06-12 - 1.1.16
|
|
4
|
+
|
|
5
|
+
- tests: properly support nulls (in testing lib)
|
|
6
|
+
- fix: initialize generic properties correctly
|
|
7
|
+
- fix: make generated imports compatible with windows
|
|
8
|
+
- feat: add support for fields marked with `readonly`
|
|
9
|
+
|
|
3
10
|
## 2025-06-09 - 1.1.15
|
|
4
11
|
|
|
5
12
|
- feat: add `.as<T>()` method to `JSON.Value`
|
|
@@ -7,8 +14,6 @@
|
|
|
7
14
|
- feat: add support for `StaticArray` serialization
|
|
8
15
|
- feat: support `JSON.Raw` in array types
|
|
9
16
|
- tests: add tests for `JSON.Raw[]`
|
|
10
|
-
- tests: properly support nulls (in testing lib)
|
|
11
|
-
- fix: initialize generic properties correctly
|
|
12
17
|
|
|
13
18
|
## 2025-05-29 - 1.1.14
|
|
14
19
|
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
|
7
7
|
█████ ███████ ██████ ██ ████ ██ ██ ███████
|
|
8
8
|
</span>
|
|
9
|
-
AssemblyScript - v1.1.
|
|
9
|
+
AssemblyScript - v1.1.16
|
|
10
10
|
</pre>
|
|
11
11
|
</h6>
|
|
12
12
|
|
|
@@ -59,7 +59,6 @@ If you'd like to see the code that the transform generates, run the build step w
|
|
|
59
59
|
```typescript
|
|
60
60
|
import { JSON } from "json-as";
|
|
61
61
|
|
|
62
|
-
|
|
63
62
|
@json
|
|
64
63
|
class Vec3 {
|
|
65
64
|
x: f32 = 0.0;
|
|
@@ -67,7 +66,6 @@ class Vec3 {
|
|
|
67
66
|
z: f32 = 0.0;
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
|
|
71
69
|
@json
|
|
72
70
|
class Player {
|
|
73
71
|
@alias("first name")
|
|
@@ -113,7 +111,6 @@ This library allows selective omission of fields during serialization using the
|
|
|
113
111
|
This decorator excludes a field from serialization entirely.
|
|
114
112
|
|
|
115
113
|
```typescript
|
|
116
|
-
|
|
117
114
|
@json
|
|
118
115
|
class Example {
|
|
119
116
|
name!: string;
|
|
@@ -133,7 +130,6 @@ console.log(JSON.stringify(obj)); // { "name": "Jairus" }
|
|
|
133
130
|
This decorator omits a field only if its value is null.
|
|
134
131
|
|
|
135
132
|
```typescript
|
|
136
|
-
|
|
137
133
|
@json
|
|
138
134
|
class Example {
|
|
139
135
|
name!: string;
|
|
@@ -153,7 +149,6 @@ console.log(JSON.stringify(obj)); // { "name": "Jairus" }
|
|
|
153
149
|
This decorator omits a field based on a custom predicate function.
|
|
154
150
|
|
|
155
151
|
```typescript
|
|
156
|
-
|
|
157
152
|
@json
|
|
158
153
|
class Example {
|
|
159
154
|
name!: string;
|
|
@@ -181,7 +176,6 @@ AssemblyScript doesn't support using nullable primitive types, so instead, json-
|
|
|
181
176
|
For example, this schema won't compile in AssemblyScript:
|
|
182
177
|
|
|
183
178
|
```typescript
|
|
184
|
-
|
|
185
179
|
@json
|
|
186
180
|
class Person {
|
|
187
181
|
name!: string;
|
|
@@ -192,7 +186,6 @@ class Person {
|
|
|
192
186
|
Instead, use `JSON.Box` to allow nullable primitives:
|
|
193
187
|
|
|
194
188
|
```typescript
|
|
195
|
-
|
|
196
189
|
@json
|
|
197
190
|
class Person {
|
|
198
191
|
name: string;
|
|
@@ -255,7 +248,6 @@ More often, objects will be completely statically typed except for one or two va
|
|
|
255
248
|
In such cases, `JSON.Value` can be used to handle fields that may hold different types at runtime.
|
|
256
249
|
|
|
257
250
|
```typescript
|
|
258
|
-
|
|
259
251
|
@json
|
|
260
252
|
class DynamicObj {
|
|
261
253
|
id: i32 = 0;
|
|
@@ -329,7 +321,6 @@ Here's an example of creating a custom data type called `Point` which serializes
|
|
|
329
321
|
```typescript
|
|
330
322
|
import { bytes } from "json-as/assembly/util";
|
|
331
323
|
|
|
332
|
-
|
|
333
324
|
@json
|
|
334
325
|
class Point {
|
|
335
326
|
x: f64 = 0.0;
|