We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e6f631e commit a22b221Copy full SHA for a22b221
src/components/ui/TextGridCode.jsx
@@ -36,7 +36,7 @@ function TextGridCode({
36
codeMode = 'xml';
37
break;
38
case 'application/ld+json':
39
- codeValue = '';
+ codeValue = formatJSON(value, 2, true) || '';
40
codeMode = 'application/ld+json';
41
42
default:
src/utils/formatJSON.js
@@ -1,4 +1,9 @@
1
-export default function formatJSON(jsonString, indent) {
+export default function formatJSON(jsonString, indent, plainOnError) {
2
if (!jsonString) return undefined;
3
- return JSON.stringify(JSON.parse(jsonString), null, indent || 2);
+ try {
4
+ return JSON.stringify(JSON.parse(jsonString), null, indent || 2);
5
+ } catch (error) {
6
+ if (plainOnError === true) return jsonString;
7
+ throw error;
8
+ }
9
}
0 commit comments