mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-02-08 12:31:16 -05:00
12 lines
184 B
TypeScript
12 lines
184 B
TypeScript
export function safeJsonParse<T>(input: string | null | undefined): T | null {
|
|
if (!input) {
|
|
return null;
|
|
}
|
|
|
|
try {
|
|
return JSON.parse(input) as T;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|