Skip to content

Commit a1759f5

Browse files
committed
PS-914 catch invalid json
1 parent dff92eb commit a1759f5

File tree

1 file changed

+6
-1
lines changed
  • databox/client/src/components/Media/Asset/Attribute/types

1 file changed

+6
-1
lines changed

databox/client/src/components/Media/Asset/Attribute/types/JsonType.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ export default class JsonType extends CodeType {
77
}
88

99
protected prettifyCode(code: string): string {
10-
return JSON.stringify(JSON.parse(code), null, 2);
10+
try {
11+
return JSON.stringify(JSON.parse(code), null, 2);
12+
} catch (e) {
13+
console.error('Error prettifying JSON code:', e);
14+
return code; // Return original code if parsing fails
15+
}
1116
}
1217
}

0 commit comments

Comments
 (0)