2.0.0 • Published 2 years ago

@serial-as/json v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

JSON-as

json-as is an assemblyscript implementation of the JSON serializer.

How to use it

Install the package via yarn add @serial-as/json and add the --transform @serial-as/transform flag to your asc command.

import { stringify, parse } from '@serial-as/json'

@serializable
class Pair{
  x: i32 = 0,
  y: i32 = 0
}

let pair:Pair = {x:1, y:2}

// `serialized` is the string "{"x":1,"y":2}"
let serialized: string = stringify(object)  

// `decoded` is the Pair = {x:1, y:2}
let decoded: Pair = parse<Pair>(serialized)