Package Exports
- @wessberg/marshaller
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 (@wessberg/marshaller) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@wessberg/marshaller
Installation
Simply do: npm install @wessberg/marshaller.
Description
This package is a lightweight way to serialize and deserialize complex data types non-destructively.
Essentially, it is JSON.parse() and JSON.stringify with support for far more data types, circular references, and with the guarantee that
whatever is serialized can be deserialized into the exact same representation without losing any information.
You can consider this to be direct replacements for the JSON.[stringify|parse] methods, provided through marshall for serialization and demarshall for deserialization.
Supported data types and features
- Anything that is JSON serializable today:
number,boolean,string,array,object literal - Circular references
RegExpDateMapSetSymbolBigIntundefinednullInt8ArrayInt16ArrayInt32ArrayUInt8ArrayUInt8ClampedArrayUInt16ArrayUInt32ArrayFloat32ArrayFloat64Array
Usage
import {marshall, demarshall} from "@wessberg/marshaller";
// Marshall some complex data that wouldn't normally be JSON serializable
const marshallResult = marshall({a: new Set([1, 2, /foo/, {a: new Date(), b: new Float32Array([1, 2, 3])}])})
// Demarshall it to get a structurally identical representation back of the data
const demarshallResult = demarshall(marshallResult);Security
Due to security considerations, you cannot marshall/demarshall functions and/or methods.