Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
█████╗ ███████╗ ██╗███████╗ ██████╗ ███╗ ██╗ ██╔══██╗██╔════╝ ██║██╔════╝██╔═══██╗████╗ ██║ ███████║███████╗█████╗ ██║███████╗██║ ██║██╔██╗ ██║ ██╔══██║╚════██║╚════╝██ ██║╚════██║██║ ██║██║╚██╗██║ ██║ ██║███████║ ╚█████╔╝███████║╚██████╔╝██║ ╚████║ ╚═╝ ╚═╝╚══════╝ ╚════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═══╝v0.8.6
npm install json-as
Add the transform to your asc
command (e.g. in package.json)
--transform json-as/transform
Alternatively, add it to your asconfig.json
{
// ...
"options": {
"transform": ["json-as/transform"]
}
}
import { JSON } from "json-as/assembly";
// @json or @serializable work here
@json
class Vec3 {
x: f32 = 0.0;
y: f32 = 0.0;
z: f32 = 0.0;
}
@json
class Player {
@alias("first name")
firstName!: string;
lastName!: string;
lastActive!: i32[];
age!: i32;
pos!: Vec3 | null;
isVerified!: boolean;
}
const player: Player = {
firstName: "Emmet",
lastName: "West",
lastActive: [8, 27, 2022],
age: 23,
pos: {
x: 3.4,
y: 1.2,
z: 8.3
},
isVerified: true
};
const stringified = JSON.stringify<Player>(player, true);
// You can toggle on setting default values with the 2nd parameter
// Alternative: use JSON.serializeTo(player, out);
const parsed = JSON.parse<Player>(stringified);
If you use this project in your codebase, consider dropping a star. I would really appreciate it!
Run or view the benchmarks here
Below are benchmark results comparing JavaScript's built-in JSON implementation and JSON-AS
My library beats JSON (written in C++) on all counts and, I see many places where I can pull at least a 60% uplift in performance if I implement it.
Serialization Benchmarks:
Value | JavaScript (ops/s) | JSON-as (ops/s) | JSON-AS with Pages |
---|---|---|---|
"hello world" | 28,629,598 | 64,210,666 | + 124% |
12345 | 31,562,431 | 56,329,066 | 321,783,941 ops/s |
1.2345 | 15,977,278 | 20,322,939 | 30,307,616 ops/s |
[[],[[]],[[],[[]]]] | 8,998,624 | 34,453,102 | + 283% |
Deserialization Benchmarks: (WIP)
Value | JavaScript (ops/s) | JSON-AS (ops/s) | % Diff |
---|---|---|---|
"12345" | 34,647,886 | 254,640,930 | + 635% |
And my PC specs:
Component | Specification |
---|---|
Wasmer Version | v4.3.0 |
CPU | AMD Ryzen 7 7800x3D @ 6.00 GHz |
Memory | T-Force DDR5 6000 MHz |
OS | Ubuntu WSL2 |
Graphics | AMD Radeon RX 6750XT |
Please submit an issue to https://github.com/JairusSW/as-json/issues if you find anything wrong with this library
FAQs
The only JSON library you'll need for AssemblyScript. SIMD enabled
The npm package json-as receives a total of 1,703 weekly downloads. As such, json-as popularity was classified as popular.
We found that json-as demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.