Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 107c632

Browse files
committed
Parse debug JSON instead of sending a string
1 parent 3cf6042 commit 107c632

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

nodecg-io-debug/dashboard/debug-helper.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ document.querySelector("#list_list_send").onclick = () => {
6969

7070
// JSON
7171
document.querySelector("#json_send").onclick = () => {
72-
const json = window.debugMonacoEditor.getValue();
73-
nodecg.sendMessage("onJSON", json);
72+
const jsonString = window.debugMonacoEditor.getValue();
73+
try {
74+
const json = JSON.parse(jsonString);
75+
nodecg.sendMessage("onJSON", json);
76+
} catch (e) {
77+
nodecg.log.error(`Cannot send invalid json: ${e}`)
78+
}
7479
};

samples/debug/extension/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module.exports = function (nodecg: NodeCG) {
4343
});
4444

4545
debug.onJSON((value) => {
46-
nodecg.log.info(`Received in 'onJSON' with JSON: ${value}`);
46+
nodecg.log.info(`Received in 'onJSON' with JSON: ${JSON.stringify(value)}`);
4747
});
4848
});
4949

0 commit comments

Comments
 (0)