mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-22 20:25:38 +00:00
Revert "Fix: Prettify JSON for Res-preview without parsing to avoid JS specific roundings"
This reverts commit 56581b3641.
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user