From 87d73b4d4085569202c1f0aa5d2a76af2581bb14 Mon Sep 17 00:00:00 2001 From: tristanessquare <44587610+tristanessquare@users.noreply.github.com> Date: Sun, 6 Nov 2022 20:19:33 +0100 Subject: [PATCH] fix(ui): decimals are not parsed correctl (#1246) replaced 'json-bigint' parser with 'lossless-json', this replacement allows for pretty-printing the json data, but still keeping the original values especially for floating numbers and bigints. fix #1006 --- client/package-lock.json | 18 +++++------------- client/package.json | 2 +- .../Topic/Topic/TopicData/TopicData.jsx | 12 ++++++------ 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/client/package-lock.json b/client/package-lock.json index 11ab0c768..e195fda65 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -3471,11 +3471,6 @@ "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==" }, - "bignumber.js": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.1.tgz", - "integrity": "sha512-IdZR9mh6ahOBv/hYGiXyVuyCetmGJhtYkqLBpTStdhEGjegpPlUawydyaF3pbIOFynJTpllEs+NP+CS9jKFLjA==" - }, "binary-extensions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.1.0.tgz", @@ -8769,14 +8764,6 @@ "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" }, - "json-bigint": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", - "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", - "requires": { - "bignumber.js": "^9.0.0" - } - }, "json-parse-better-errors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", @@ -9321,6 +9308,11 @@ "js-tokens": "^3.0.0 || ^4.0.0" } }, + "lossless-json": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/lossless-json/-/lossless-json-2.0.1.tgz", + "integrity": "sha512-KW/FSL426qblKVvf4ImeMVGr0Je6J9aXvAMUOIU8AzelDj06q47mn6QJ+56lBBd+A8kjrncrxdKQs6ZssAXTmw==" + }, "loud-rejection": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", diff --git a/client/package.json b/client/package.json index 4f44bb920..2e7d483d2 100644 --- a/client/package.json +++ b/client/package.json @@ -17,7 +17,7 @@ "css-loader": "^3.4.1", "font-awesome": "^4.7.0", "joi-validation": "^2.0.0", - "json-bigint": "^1.0.0", + "lossless-json": "^2.0.1", "lodash": "^4.17.21", "moment": "^2.24.0", "node-sass": "^4.14.1", diff --git a/client/src/containers/Topic/Topic/TopicData/TopicData.jsx b/client/src/containers/Topic/Topic/TopicData/TopicData.jsx index fc0166902..923eab72b 100644 --- a/client/src/containers/Topic/Topic/TopicData/TopicData.jsx +++ b/client/src/containers/Topic/Topic/TopicData/TopicData.jsx @@ -30,7 +30,7 @@ import DateTime from '../../../../components/DateTime'; import { capitalizeTxt, getClusterUIOptions } from '../../../../utils/functions'; import { setProduceToTopicValues, setUIOptions} from '../../../../utils/localstorage'; import Select from '../../../../components/Form/Select'; -import JSONbig from 'json-bigint'; +import * as LosslessJson from 'lossless-json' class TopicData extends Root { state = { @@ -928,8 +928,8 @@ class TopicData extends Root { extraRowContent: (obj, index) => { let value = obj.value; try { - let json = JSONbig.parse(obj.value); - value = JSONbig.stringify(json, null, 2); + let json = LosslessJson.parse(obj.value); + value = LosslessJson.stringify(json, undefined, " "); // eslint-disable-next-line no-empty } catch (e) {} @@ -969,9 +969,9 @@ class TopicData extends Root { colName: 'Date', type: 'text', cell: (obj, col) => { - return ; } },