think/packages/client/src/helpers/json.tsx

8 lines
143 B
TypeScript
Raw Normal View History

2022-02-20 11:51:55 +00:00
export const safeJSONParse = (str, defaultValue = {}) => {
try {
return JSON.parse(str);
} catch (e) {
return defaultValue;
}
};