Skip to content

Commit a22b221

Browse files
committed
Display metadata dataset value
1 parent e6f631e commit a22b221

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/components/ui/TextGridCode.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function TextGridCode({
3636
codeMode = 'xml';
3737
break;
3838
case 'application/ld+json':
39-
codeValue = '';
39+
codeValue = formatJSON(value, 2, true) || '';
4040
codeMode = 'application/ld+json';
4141
break;
4242
default:

src/utils/formatJSON.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
export default function formatJSON(jsonString, indent) {
1+
export default function formatJSON(jsonString, indent, plainOnError) {
22
if (!jsonString) return undefined;
3-
return JSON.stringify(JSON.parse(jsonString), null, indent || 2);
3+
try {
4+
return JSON.stringify(JSON.parse(jsonString), null, indent || 2);
5+
} catch (error) {
6+
if (plainOnError === true) return jsonString;
7+
throw error;
8+
}
49
}

0 commit comments

Comments
 (0)