import superjson from 'superjson'; export function getSafeJson(str: string): T | null { try { return JSON.parse(str); } catch (e) { return null; } } export function getSuperJson(str: string): T | null { const json = getSafeJson(str); if (typeof json === 'object' && json !== null && 'json' in json) { return superjson.parse(str); } return json; } export function setSuperJson(str: any): string { return superjson.stringify(str); }