JSON.prune
JSON.prune copied to clipboard
support for indentation?
Standerted JSON.stringify allows an argument for \t and \n for indentation purposes as follows:
JSON.stringify({ uno: 1, dos: 2 }, null, '\t');
// returns the string:
// '{
// "uno": 1,
// "dos": 2
// }'
JSON.prune supports it as well?
At the moment there's no support for improved formatting, and it can't follow the same exact syntax because the second argument is an option object.
This could be modified but I'm not sure there's really a need.
If you're not performance tied, you can use JSON.prune
to produce a pruned object then use the standard representation:
let pruned = JSON.parse(JSON.prune(yourObject));
let json = JSON.stringify(pruned, null, '\t');