Returns a converter for JSON-compatible objects or values.
encode first serializes the object
or value to JSON and then converts the resulting string to an ArrayBuffer.
JSON serialization uses JSON.stringify() without replacer or
space parameters.
decode converts the ArrayBuffer
to a string and parses it using JSON.parse() without reviver
parameter.
Example:
interfacePerson { name: string age: number } constperson: Person = { name:"John", age:42 }; constconv = ccfapp.json<Person>(); constbuffer = conv.encode(person); // ArrayBuffer constperson2 = conv.decode(buffer); // Person
Returns a converter for JSON-compatible objects or values.
encode
first serializes the object or value to JSON and then converts the resulting string to anArrayBuffer
. JSON serialization usesJSON.stringify()
withoutreplacer
orspace
parameters.decode
converts theArrayBuffer
to a string and parses it usingJSON.parse()
withoutreviver
parameter.Example: