
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
JSON for AssemblyScript focused on performance, low-overhead, and ease-of-use.
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;
y!: f32;
z!: f32;
}
@json
class Player {
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);
const parsed = JSON.parse<Player>(stringified);
This implementation does not hold strongly to the JSON specification. Rather, design and behavior are inspired by the JSON implementation found in Google's v8 engine.
removeWhitespace
function provided by json-as/src/util.ts
Fully supports:
Number parsing speed has doubled over the last 5 versions due to the use of a atoi_fast
function found in assembly/util.ts
. This can be further optimized with SIMD.
String serialization has more than tripled in performance (+360%). The algorithm was rewritten for less if statements and more traps.
String deserialization was quadrupled from 3.4m ops to 14.8 ops (435%). It went from using .replaceAll
to a specialized algorithm.
Schema (object) parsing is being optimized on GitHub and should be at least doubled if not tripled. (Current speed of barely-optimized version is 6.9m ops) This is due to taking advantage of the types with a type map and eliminating extra checking.
Serialize Object (Vec3): 6.7m ops/5s
Deserialize Object (Vec3): 5.1m ops/5s
Serialize Array (int[]): 6.6m ops/5s
Deserialize Array (int[]): 8.6m ops/5s
Serialize String (5): 5.9m ops/5s
Deserialize String (5): 16.3m ops/5s
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 634 weekly downloads. As such, json-as popularity was classified as not 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 1 open source maintainer 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.