Files
api/app/core/utils/misc/attempt-json-parse.ts
2021-07-01 16:40:47 +09:30

8 lines
149 B
TypeScript

export const attemptJSONParse = (text: string, fallback: any = undefined) => {
try {
return JSON.parse(text);
} catch {
return fallback;
}
};