diff --git a/package-lock.json b/package-lock.json index 67bfa6c95..be8bc091c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18862,4 +18862,4 @@ } } } -} +} \ No newline at end of file diff --git a/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js b/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js index ee956f1b1..da713a2c9 100644 --- a/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js +++ b/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js @@ -19,11 +19,23 @@ const formatResponse = (data, mode, filter) => { } if (mode.includes('json')) { + let isValidJSON = false; + + try { + isValidJSON = typeof JSON.parse(JSON.stringify(data)) === 'object'; + } catch (error) { + console.log('Error parsing JSON: ', error.message); + } + + if (!isValidJSON || data === null) { + return data; + } + if (filter) { try { data = JSONPath({ path: filter, json: data }); } catch (e) { - console.warn('Could not filter with JSONPath.', e.message); + console.warn('Could not apply JSONPath filter:', e.message); } } @@ -35,15 +47,10 @@ const formatResponse = (data, mode, filter) => { if (typeof parsed === 'string') { return parsed; } - return safeStringifyJSON(parsed, true); } - if (typeof data === 'string') { - return data; - } - - return safeStringifyJSON(data); + return data; }; const QueryResult = ({ item, collection, data, dataBuffer, width, disableRunEventListener, headers, error }) => {