Files
api/app/core/utils/misc/attempt-json-parse.ts
Alexis 010efe75bd Revert "chore: lint all the files"
This reverts commit 4ef387b5bb.
2021-09-07 13:46:23 +09:30

8 lines
149 B
TypeScript

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