You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP

json-as

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
j

json-as

JSON encoder/decoder for AssemblyScript

0.5.4
76

Supply Chain Security

100

Vulnerability

95

Quality

86

Maintenance

100

License

Unpopular package

Quality

This package is not very popular.

Found 1 instance in 1 package

Version published
Weekly downloads
1K
-54.65%
Maintainers
1
Weekly downloads
 
Created
Issues
0

AS-JSON

JSON serializer/deserializer for AssemblyScript

Installation

~ npm install json-as
~ npm install visitor-as

Add the transform to your asc command

--transform json-as/transform

Or, add it to asconfig.json

{
  "options": {
    "transform": "json-as/transform"
  }
}

Usage

import { JSON } from "json-as/assembly";

@json
class Vec2 {
  x: f32
  y: f32
}

@json
class Player {
  firstName: string
  lastName: string
  lastActive: i32[]
  age: i32
  pos: Vec2
  isVerified: boolean
}

const data: Player = {
  firstName: "Emmet",
  lastName: "West",
  lastActive: [8, 27, 2022],
  age: 23,
  pos: {
    x: -3.4,
    y: 1.2
  },
  isVerified: true
}

const stringified = JSON.stringify<Player>(data);

const parsed = JSON.parse<Player>(stringified);

Performance

Serialize Object (Vec2): ~7.20m ops/s

Deserialize Object (Vec2): ~2.2m ops/s

Serialize Array (int[4]): ~1.4m ops/s

Deserialize Array (int[4]): ~2.8m ops/s

Serialize String (5): ~5.2m ops/sw

Deserialize String (5): ~1.36m ops/s

Issues

Please submit an issue to https://github.com/JairusSW/as-json/issues if you find anything wrong with this library

FAQs

Package last updated on 28 Oct 2022

Did you know?

Socket

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.

Install

Related posts