Core views frontend (#13932)
Parallel code path to read and write core views when IS_CORE_VIEW_ENABLED. Migrated view key to an enum. --------- Co-authored-by: Charles Bochet <charles@twenty.com> Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
export const parseJson = <T>(json: string): T | null => {
|
||||
import { isDefined } from "@/utils/validation";
|
||||
|
||||
export const parseJson = <T>(rawJson: string | boolean | null | number): T | null => {
|
||||
try {
|
||||
return JSON.parse(json);
|
||||
if (!isDefined(rawJson)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// This is a hack to handle the case where the value is a scalar value which is part of JSON spec but not implemented before ES2019
|
||||
return JSON.parse("[" + rawJson + "]")[0];
|
||||
} catch {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user