Skip to content

Commit

Permalink
fix(ui): decimals are not parsed correctl (#1246)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tristanexsquare authored Nov 6, 2022
1 parent e57cc02 commit 87d73b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
18 changes: 5 additions & 13 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions client/src/containers/Topic/Topic/TopicData/TopicData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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) {}

Expand Down Expand Up @@ -969,9 +969,9 @@ class TopicData extends Root {
colName: 'Date',
type: 'text',
cell: (obj, col) => {
return <DateTime
isoDateTimeString={obj[col.accessor]}
dateTimeFormat={this.state.dateTimeFormat}
return <DateTime
isoDateTimeString={obj[col.accessor]}
dateTimeFormat={this.state.dateTimeFormat}
/>;
}
},
Expand Down

0 comments on commit 87d73b4

Please sign in to comment.