Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import { ISerializer } from './ISerializer';
const serialize = <T>(data: T): string => {
return JSON.stringify(data);
};
const deserialize = <T>(data: string): T => {
return JSON.parse(data) as T;
};
/**
* De/Serialize JSON objects with the native JSON.stringify and JSON.parse
*/
export class JsonSerializer<T extends Record<string, unknown> | Array<unknown>>
implements ISerializer<T>
{
serialize = serialize;
deserialize = deserialize;
}
|