You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+75-64Lines changed: 75 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,28 @@
6
6
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
7
7
█████ ███████ ██████ ██ ████ ██ ██ ███████
8
8
</span>
9
-
AssemblyScript - v1.0.0-beta.17
9
+
AssemblyScript - v1.0.0-beta.18
10
10
</pre>
11
11
</h5>
12
12
13
13
## 📝 About
14
14
15
15
JSON is the de-facto serialization format of modern web applications, but its serialization and deserialization remain a significant performance bottleneck, especially at scale. Traditional parsing approaches are computationally expensive, adding unnecessary overhead to both clients and servers. This library is designed to mitigate this by leveraging SIMD acceleration and highly optimized transformations.
16
16
17
+
## 🚨 What's new in v1.0.0
18
+
19
+
🔹Breaking changes to the way custom serializers/deserializers function (See Custom Serializers below)
20
+
21
+
🔹Major performance improvements and addition of SIMD
22
+
23
+
🔹Extremely low memory overhead compared to pre-1.x.x versions (great for serverless workloads)
24
+
25
+
🔹Fixes to many major issues and newly discovered bugs
26
+
27
+
🔹Full support for dynamic objects, arrays, and values
28
+
29
+
🔹Full support for `JSON.Raw` type everywhere
30
+
17
31
## 📚 Contents
18
32
19
33
-[Installation](#-installation)
@@ -31,22 +45,22 @@ JSON is the de-facto serialization format of modern web applications, but its se
31
45
## 💾 Installation
32
46
33
47
```bash
34
-
npm install json-as@1.0.0-beta.17
48
+
npm install json-as@1.0.0-beta.18
35
49
```
36
50
37
51
Add the `--transform` to your `asc` command (e.g. in package.json)
@@ -296,7 +325,8 @@ This library supports custom serialization and deserialization methods, which ca
296
325
297
326
Here's an example of creating a custom data type called `Point` which serializes to `(x,y)`
298
327
299
-
```js
328
+
```typescript
329
+
300
330
@json
301
331
classPoint {
302
332
x:f64=0.0;
@@ -306,11 +336,13 @@ class Point {
306
336
this.y=y;
307
337
}
308
338
339
+
309
340
@serializer
310
341
serializer(self:Point):string {
311
342
return`(${self.x},${self.y})`;
312
343
}
313
344
345
+
314
346
@deserializer
315
347
deserializer(data:string):Point {
316
348
const dataSize =bytes(data);
@@ -320,10 +352,7 @@ class Point {
320
352
const x =data.slice(1, c);
321
353
const y =data.slice(c+1, data.length-1);
322
354
323
-
returnnewPoint(
324
-
f64.parse(x),
325
-
f64.parse(y)
326
-
);
355
+
returnnewPoint(f64.parse(x), f64.parse(y));
327
356
}
328
357
}
329
358
```
@@ -334,7 +363,7 @@ The deserializer function parses the string `(x,y)` back into a `Point` instance
334
363
335
364
These functions are then wrapped before being consumed by the json-as library:
336
365
337
-
```js
366
+
```typescript
338
367
@inline__SERIALIZE_CUSTOM(ptr: usize): void {
339
368
const data =this.serializer(changetype<Point>(ptr));
340
369
const dataSize =data.length<<1;
@@ -353,45 +382,27 @@ This allows custom serialization while maintaining a generic interface for the l
353
382
354
383
The `json-as` library has been optimized to achieve near-gigabyte-per-second JSON processing speeds through SIMD acceleration and highly efficient transformations. Below are some key performance benchmarks to give you an idea of how it performs.
355
384
356
-
### Raw Performance
357
-
358
-
Simple
359
-
360
-
| Test Case | Serialization (ops/s) | Deserialization (ops/s) | Serialization (MB/s) | Deserialization (MB/s) |
| Small JSON Object |[Fill Value]|[Fill Value]|[Fill Value]|[Fill Value]|
375
-
| Medium JSON Object |[Fill Value]|[Fill Value]|[Fill Value]|[Fill Value]|
376
-
| Large JSON Object |[Fill Value]|[Fill Value]|[Fill Value]|[Fill Value]|
385
+
Note: the AssemblyScript benches are run using a _bump allocator_ so that Garbage Collection does not interfere with results. Also note that ideally, I would use [d8](https://v8.dev/docs/d8), but until that is done, these results serve as a temporary performance comparison.
377
386
378
-
JavaScript
387
+
**Table 1** - _AssemblyScript_
379
388
380
-
| Test Case | Serialization (ops/s) | Deserialization (ops/s) | Serialization (MB/s) | Deserialization (MB/s) |
@@ -404,4 +415,4 @@ Please send all issues to [GitHub Issues](https://github.com/JairusSW/json-as/is
404
415
-**Email:** Send me inquiries, questions, or requests at [me@jairus.dev](mailto:me@jairus.dev)
405
416
-**GitHub:** Visit the official GitHub repository [Here](https://github.com/JairusSW/json-as)
406
417
-**Website:** Visit my official website at [jairus.dev](https://jairus.dev/)
407
-
-**Discord:** Contact me at [My Discord](https://discord.com/users/600700584038760448) or on the [AssemblyScript Discord Server](https://discord.gg/assemblyscript/)
418
+
-**Discord:** Contact me at [My Discord](https://discord.com/users/600700584038760448) or on the [AssemblyScript Discord Server](https://discord.gg/assemblyscript/)
0 commit comments