fix: use fast-json-format for prettifying json (#6026)

This commit is contained in:
lohit
2025-11-07 16:20:12 +05:30
committed by GitHub
parent 24a36bc355
commit ab4e9eb3bd
5 changed files with 7 additions and 63 deletions

View File

@@ -8,7 +8,7 @@ import { humanizeRequestBodyMode } from 'utils/collections';
import StyledWrapper from './StyledWrapper';
import { updateRequestBody } from 'providers/ReduxStore/slices/collections/index';
import { toastError } from 'utils/common/error';
import { prettifyJSON } from 'utils/common';
import fastJsonFormat from 'fast-json-format';
import xmlFormat from 'xml-formatter';
const RequestBodyMode = ({ item, collection }) => {
@@ -39,7 +39,7 @@ const RequestBodyMode = ({ item, collection }) => {
const onPrettify = () => {
if (body?.json && bodyMode === 'json') {
try {
const prettyBodyJson = prettifyJSON(body.json);
const prettyBodyJson = fastJsonFormat(body.json);
dispatch(
updateRequestBody({
content: prettyBodyJson,

View File

@@ -10,7 +10,7 @@ import React, { useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { autoDetectLang } from 'utils/codemirror/lang-detect';
import { toastError } from 'utils/common/error';
import { prettifyJSON } from 'utils/common/index';
import fastJsonFormat from 'fast-json-format';
import xmlFormat from 'xml-formatter';
import WSRequestBodyMode from '../BodyMode/index';
@@ -105,7 +105,7 @@ export const SingleWSMessage = ({
const onPrettify = () => {
if (codeType === 'json') {
try {
const prettyBodyJson = prettifyJSON(content);
const prettyBodyJson = fastJsonFormat(content);
const currentMessages = [...(body.ws || [])];
currentMessages[index] = {
...currentMessages[index],