diff --git a/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js b/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js index 927b13314..81bcaca7e 100644 --- a/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js +++ b/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js @@ -27,14 +27,13 @@ const formatResponse = (data, mode, filter) => { let isValidJSON = false; try { - isValidJSON = - typeof JSON.parse(JSON.stringify(data)) === 'object' || typeof JSON.parse(JSON.stringify(data)) === 'string'; + isValidJSON = typeof JSON.parse(JSON.stringify(data)) === 'object' } catch (error) { console.log('Error parsing JSON: ', error.message); } if (!isValidJSON && typeof data === 'string') { - return data; + return JSON.stringify(data); } if (filter) { diff --git a/packages/bruno-electron/src/ipc/network/index.js b/packages/bruno-electron/src/ipc/network/index.js index 9e37c8289..479cb0d04 100644 --- a/packages/bruno-electron/src/ipc/network/index.js +++ b/packages/bruno-electron/src/ipc/network/index.js @@ -366,7 +366,10 @@ const parseDataFromResponse = (response, disableParsingResponseJson = false) => // Filter out ZWNBSP character // https://gist.github.com/antic183/619f42b559b78028d1fe9e7ae8a1352d data = data.replace(/^\uFEFF/, ''); - if (!disableParsingResponseJson) { + if ( + !disableParsingResponseJson + && !(data.startsWith("\"") && data.endsWith("\"")) // a quoated string is also a vaild json but we want to show it as a quoated string only (parsing removes the quoates) + ) { data = JSON.parse(data); } } catch { }