mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
14 lines
459 B
TypeScript
14 lines
459 B
TypeScript
import LosslessJSON = require('lossless-json');
|
|
|
|
LosslessJSON.config({ circularRefs: false });
|
|
|
|
const parsed = LosslessJSON.parse('{ "n": 123 }', (key, value) => {
|
|
if (key && value && value instanceof LosslessJSON.LosslessNumber) {
|
|
return value.valueOf();
|
|
}
|
|
return value;
|
|
});
|
|
|
|
const str = LosslessJSON.stringify({ n: new LosslessJSON.LosslessNumber(parsed.n) }, undefined, 2);
|
|
if (typeof str !== 'string') throw new Error('not a string');
|