Skip to content

Commit

Permalink
fix: precision lost when json is beautified
Browse files Browse the repository at this point in the history
  • Loading branch information
nivedin committed Jun 3, 2024
1 parent d0350ec commit d2f8e2d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/hoppscotch-common/src/components/http/RawBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import { readFileAsText } from "~/helpers/functional/files"
import xmlFormat from "xml-formatter"
import { useNestedSetting } from "~/composables/settings"
import { toggleNestedSetting } from "~/newstore/settings"
import * as LJSON from "lossless-json"
type PossibleContentTypes = Exclude<
ValidContentTypes,
Expand Down Expand Up @@ -187,8 +188,8 @@ const prettifyRequestBody = () => {
let prettifyBody = ""
try {
if (body.value.contentType.endsWith("json")) {
const jsonObj = JSON.parse(rawParamsBody.value as string)
prettifyBody = JSON.stringify(jsonObj, null, 2)
const jsonObj = LJSON.parse(rawParamsBody.value as string)
prettifyBody = LJSON.stringify(jsonObj, undefined, 2) as string
} else if (body.value.contentType === "application/xml") {
prettifyBody = prettifyXML(rawParamsBody.value as string)
}
Expand Down

0 comments on commit d2f8e2d

Please sign in to comment.