From 7622a4aaae365cb730d08ed8c744041cc2b3a35b Mon Sep 17 00:00:00 2001 From: ramki-bruno Date: Tue, 25 Mar 2025 21:13:51 +0530 Subject: [PATCH] Revert "Fix: Prettify JSON for Res-preview without parsing to avoid JS specific roundings" This reverts commit 56581b36413e2e803381182d1b1f20c77edca98b. --- .../src/components/ResponsePane/QueryResult/index.js | 9 +++------ packages/bruno-app/src/utils/common/index.js | 8 -------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js b/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js index 78993a413..07f4a091b 100644 --- a/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js +++ b/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js @@ -10,7 +10,7 @@ import QueryResultPreview from './QueryResultPreview'; import StyledWrapper from './StyledWrapper'; import { useState, useMemo, useEffect } from 'react'; import { useTheme } from 'providers/Theme/index'; -import { getEncoding, prettifyJson, uuid } from 'utils/common/index'; +import { getEncoding, uuid } from 'utils/common/index'; const formatResponse = (data, dataBuffer, encoding, mode, filter) => { if (data === undefined || !dataBuffer) { @@ -37,15 +37,12 @@ const formatResponse = (data, dataBuffer, encoding, mode, filter) => { if (filter) { try { data = JSONPath({ path: filter, json: data }); - return prettifyJson(JSON.stringify(data)); } catch (e) { console.warn('Could not apply JSONPath filter:', e.message); } } - // Prettify the JSON string directly instead of parse->stringify to avoid - // issues like rounding numbers bigger than Number.MAX_SAFE_INTEGER etc. - return prettifyJson(rawData); + return safeStringifyJSON(data, true); } if (mode.includes('xml')) { @@ -60,7 +57,7 @@ const formatResponse = (data, dataBuffer, encoding, mode, filter) => { return data; } - return prettifyJson(rawData); + return safeStringifyJSON(data, true); }; const formatErrorMessage = (error) => { diff --git a/packages/bruno-app/src/utils/common/index.js b/packages/bruno-app/src/utils/common/index.js index 14fd8805a..8ab235426 100644 --- a/packages/bruno-app/src/utils/common/index.js +++ b/packages/bruno-app/src/utils/common/index.js @@ -1,6 +1,5 @@ import { customAlphabet } from 'nanoid'; import xmlFormat from 'xml-formatter'; -import { format as jsoncFormat, applyEdits as jsoncApplyEdits } from 'jsonc-parser'; // a customized version of nanoid without using _ and - export const uuid = () => { @@ -27,13 +26,6 @@ export const waitForNextTick = () => { }); }; -export const prettifyJson = (doc) => { - return jsoncApplyEdits( - doc, - jsoncFormat(doc, null, {insertSpaces: true, tabSize: 2}) - ); -} - export const safeParseJSON = (str) => { if (!str || !str.length || typeof str !== 'string') { return str;