diff --git a/src/ts/background.js b/src/ts/background.js index 420b21c..d38b6e7 100644 --- a/src/ts/background.js +++ b/src/ts/background.js @@ -1,7 +1,7 @@ import jq from 'jq-web/jq.wasm.js'; function getJq(jsonInput, filter = '.') { - return jq.raw(jsonInput, filter); + return jq(JSON.parse(jsonInput), filter); } // Build the connection to the frontend @@ -11,9 +11,9 @@ chrome.runtime.onConnect.addListener(port => { // Listen to messages from frontend port.onMessage.addListener(msg => { // Filter the JSON with JQ - const jqResult = getJq(msg.json, msg.filter); + const jqResult = JSON.stringify(getJq(msg.json, msg.filter)); // Send the result from JQ to the frontend port.postMessage({ jqResult: jqResult }); }); } -}); +}); \ No newline at end of file diff --git a/src/ts/ui.ts b/src/ts/ui.ts index b3f5928..a0716e8 100644 --- a/src/ts/ui.ts +++ b/src/ts/ui.ts @@ -59,6 +59,7 @@ export function renderCss() { } export function updateOutput(output) { + output = JSON.stringify(JSON.parse(output), null, 2); const editor = ace.edit('json-editor-output'); editor.setValue(output); editor.clearSelection();