A Bus that parses JSON. This is a convenience wrapper around the JSON.parse and JSON.stringify functions, if you need more advanced functionality, you should use the Bus.create function.
import * as io from "@prelude-io/core";const CatFactCount = io.JSON.chain( io.Complex("CatFactRequest", { facts: io.number, }));console.log(await CatFactCount.deserialize('{ "facts": 4 }')); // => IORight containing `{ facts: 4 }`console.log(await CatFactCount.serialize({ facts: 4 })); // => IORight containing `'{ "facts": 4 }'` Copy
import * as io from "@prelude-io/core";const CatFactCount = io.JSON.chain( io.Complex("CatFactRequest", { facts: io.number, }));console.log(await CatFactCount.deserialize('{ "facts": 4 }')); // => IORight containing `{ facts: 4 }`console.log(await CatFactCount.serialize({ facts: 4 })); // => IORight containing `'{ "facts": 4 }'`
Generated using TypeDoc
A Bus that parses JSON. This is a convenience wrapper around the JSON.parse and JSON.stringify functions, if you need more advanced functionality, you should use the Bus.create function.
Example