json-pack example

node v18.11.0
version: 1.0.0
endpointsharetweet
require("tslib") const {JsonEncoder} = require('json-joy/es2020/json-pack/json/JsonEncoder'); const {JsonDecoder} = require('json-joy/es2020/json-pack/json/JsonDecoder'); const {Writer} = require('json-joy/es2020/util/buffers/Writer'); const obj = { foo: 1, bar: "hello", binary: new Uint8Array([1, 2, 3]), }; const encoder = new JsonEncoder(new Writer()); const encoded = encoder.encode(obj); const decoder = new JsonDecoder(); const decoded = decoder.read(encoded); console.log(decoded);
Loading…

no comments

    sign in to comment