For lower-level access to the split json and meta data, use serialize and deserialize. This is useful for APIs that need to remain JSON-compatible for standard clients while providing metadata for Superjson-enabled clients.
const object = {
normal: 'string',
timestamp: new Date(),
test: /superjson/,
};
const { json, meta } = superjson.serialize(object);
/*
json = {
normal: 'string',
timestamp: "2020-06-20T04:56:50.293Z",
test: "/superjson/",
};
meta = {
values: {
timestamp: ['Date'],
test: ['regexp'],
}
};
*/
// To restore the object:
deserialize({ json, meta }, { inPlace: true });