mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
27 lines
711 B
TypeScript
27 lines
711 B
TypeScript
import CircularJSON = require('circular-json');
|
|
|
|
const replacer = (key: any, val: any) => {
|
|
return val;
|
|
};
|
|
|
|
const replacerArray = ['a', 'x'];
|
|
|
|
CircularJSON.parse('{"a":"b"}');
|
|
|
|
CircularJSON.parse('{"a":"b"}', replacer);
|
|
|
|
// just stringify a value
|
|
CircularJSON.stringify({a: 'b'});
|
|
|
|
// do replacements for part of the object
|
|
CircularJSON.stringify({a: 'b'}, replacer);
|
|
CircularJSON.stringify({a: 'b'}, replacerArray);
|
|
|
|
// add whitespace to the output
|
|
CircularJSON.stringify({a: 'b'}, replacer, 5);
|
|
CircularJSON.stringify({a: 'b'}, replacerArray, 5);
|
|
|
|
// do not actually set up a re-parseable object
|
|
CircularJSON.stringify({a: 'b'}, replacer, 5, true);
|
|
CircularJSON.stringify({a: 'b'}, replacerArray, 5, true);
|