fix: BigInters are now correctly shown in the response (#2736)

Fixes: #1753
This commit is contained in:
Timon 2024-08-06 09:31:30 +02:00 committed by GitHub
parent aa4bcdca9b
commit 3e2a3b65a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 3 deletions

View File

@ -1,5 +1,6 @@
import { customAlphabet } from 'nanoid'; import { customAlphabet } from 'nanoid';
import xmlFormat from 'xml-formatter'; import xmlFormat from 'xml-formatter';
import { stringify } from 'lossless-json';
// a customized version of nanoid without using _ and - // a customized version of nanoid without using _ and -
export const uuid = () => { export const uuid = () => {
@ -43,9 +44,9 @@ export const safeStringifyJSON = (obj, indent = false) => {
} }
try { try {
if (indent) { if (indent) {
return JSON.stringify(obj, null, 2); return stringify(obj, null, 2);
} }
return JSON.stringify(obj); return stringify(obj);
} catch (e) { } catch (e) {
return obj; return obj;
} }

View File

@ -50,6 +50,7 @@
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"json-bigint": "^1.0.0", "json-bigint": "^1.0.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"lossless-json": "^4.0.1",
"mime-types": "^2.1.35", "mime-types": "^2.1.35",
"mustache": "^4.2.0", "mustache": "^4.2.0",
"nanoid": "3.3.4", "nanoid": "3.3.4",

View File

@ -38,6 +38,7 @@ const {
} = require('./oauth2-helper'); } = require('./oauth2-helper');
const Oauth2Store = require('../../store/oauth2'); const Oauth2Store = require('../../store/oauth2');
const iconv = require('iconv-lite'); const iconv = require('iconv-lite');
const { parse, LosslessNumber } = require('lossless-json');
// override the default escape function to prevent escaping // override the default escape function to prevent escaping
Mustache.escape = function (value) { Mustache.escape = function (value) {
@ -285,7 +286,11 @@ const parseDataFromResponse = (response) => {
// Filter out ZWNBSP character // Filter out ZWNBSP character
// https://gist.github.com/antic183/619f42b559b78028d1fe9e7ae8a1352d // https://gist.github.com/antic183/619f42b559b78028d1fe9e7ae8a1352d
data = data.replace(/^\uFEFF/, ''); data = data.replace(/^\uFEFF/, '');
data = JSON.parse(data); data = parse(data, null, (value) => {
// By default, this will return the LosslessNumber object, but because it's passed into ipc we
// need to convert it into a number because LosslessNumber is converted into an object
return new LosslessNumber(value).valueOf();
});
} catch {} } catch {}
return { data, dataBuffer }; return { data, dataBuffer };