Package Exports
- json-as
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (json-as) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
AS-JSON
JSON encoder/decoder for AssemblyScript
Installation
~ npm install json-as--transform json-as/transformUsage
import { JSON } from 'json-as'Object (schema)
@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
const stringified = JSON.stringify(["hello","world"])
// '["hello","world"]'
const parsed = JSON.parse<Array<string>>(stringified)
// ["hello", "world"]String
const stringified = JSON.stringify('hello world')
// '"hello world"'
const parsed = JSON.parse<string>(stringified)
// hello worldNumbers
const stringified = JSON.stringify(3.14)
// '3.14'
const parsed = JSON.parse<f64>(stringified)
// 3.14Booleans
const stringified = JSON.stringify(true)
// 'true'
const parsed = JSON.parse<boolean>(stringified)
// true