
Security News
Node.js Homepage Adds Paid Support Link, Prompting Contributor Pushback
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
JSON encoder/decoder for AssemblyScript
~ npm install json-as
--transform json-as/transform
import { JSON, unknown } from 'json-as'
Object
@json
class JSONSchema {
firstName: string
lastName: string
age: i32
}
const data: JSONSchema {
firstName: 'Jairus',
lastName: 'Tanaka',
age: 14
}
const stringified = JSON.stringify(data)
// '{"firstName":"Jairus","lastName":"Tanaka","age":14}'
const parsed = JSON.parse<JSONSchema>(stringified)
// { firstName: "Jairus", lastName: "Tanaka", age: 14 }
Array (Typed)
const stringified = JSON.stringify(['Hello', 'World'])
// '["Hello","World"]'
const parsed = JSON.parse<JSONSchema>(stringified)
// ["Hello", "World"]
Array (Dynamic)
const stringified = JSON.stringify(["Welcome to dynamic arrays", 3.14, ["Deep"], true, "It also supports nulls", null])
// '["Welcome to dynamic arrays",3.14,["Deep"],true,"It also supports nulls",null]'
const parsed = JSON.parse<unknown[]>(stringified)
// ["Welcome to dynamic arrays", 3.14, ["Deep"], true, "It also supports nulls", null]
Float
const stringified = JSON.stringify(3.14)
// '3.14'
const parsed = JSON.parse<f64>(stringified)
// 3.14
Integer
const stringified = JSON.stringify(14)
// '14'
const parsed = JSON.parse<i32>(stringified)
// 14
Boolean
const stringified = JSON.stringify(true)
// 'true'
const parsed = JSON.parse<boolean>(stringified)
// true
Bool
const stringified = JSON.stringify(true)
// 'true'
const parsed = JSON.parse<bool>(stringified)
// true
Null
const stringified = JSON.stringify(null)
// 'null'
const parsed = JSON.parse(stringified)
// null
Breaking changes for v2.0.0! Experimental usage only
const parsed = JSON.parse<unknown[]>(["Welcome to dynamic arrays",3.14,["Deep"],true,"It also supports nulls",null])
console.log(parsed[0].get<string>())
// "Welcome to dynamic arrays"
console.log(parsed[1].get<f64>().toString())
// 3.14
AS-JSON Stringify String: ~1858051.4 ops/s | 53.82ms
AS-JSON Parse String: ~4321632.43 ops/s | 23.14ms
AS-JSON Stringify Integer: ~8529956.89 ops/s | 11.72ms
AS-JSON Parse Integer: ~27839325.77 ops/s | 3.59ms
AS-JSON Stringify Float: ~5128590.39 ops/s | 19.5ms
AS-JSON Parse Float: ~21467505.24 ops/s | 4.66ms
AS-JSON Stringify Boolean: ~361837455.83 ops/s | 0.28ms
AS-JSON Parse Boolean: ~51522012.58 ops/s | 1.94ms
AS-JSON Stringify Array: ~1421792.72 ops/s | 70.33ms
AS-JSON Parse Array: ~3755593.05 ops/s | 26.63ms
AS-JSON Stringify Object: ~3309471.1 ops/s | 30.22ms
AS-JSON Parse Object: ~1054387.45 ops/s | 94.84ms
AS-JSON Stringify Dynamic Array: ~285433.75 ops/s | 350.34ms
AS-JSON Parse Dynamic Array: ~661516.87 ops/s | 151.17ms
FAQs
The only JSON library you'll need for AssemblyScript. SIMD enabled
The npm package json-as receives a total of 2,627 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 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
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.
Research
Security News
The Socket Research Team investigates a malicious Python typosquat of a popular password library that forces Windows shutdowns when input is incorrect.