js-beautify
js-beautify copied to clipboard
Feature request: strip keys with default json values
Description
A new feature flag (ex: stripDefaultValues
) removes json keys that have default json values: null
, zero
(integer / number), empty array
, empty object
and boolean false
.
Note: empty string is not a default value.
Input
With this new feature, when I give like this input:
{
"a" : null,
"b": "",
"c": 0,
"d": 0.0,
"e": false,
"f" : {},
"g": [],
"h": {
"i": null
"j": {
"k": false
}
}
}
Expected Output
I'd like to see this output:
{
"b": ""
}
Environment
OS: any
Hi! I would like to work on this issue. Are there any steps I need to take before doing so, besides what was stated in CONTRIBUTING.md?
@a-vento If you would like to contribute in general there are other issues I would point you to before this one.
I don't know why I didn't comment on this earlier, but the beautifier is primarily a whitespace-only reformatter. We generally avoid features that change the text of code or the functional behavior of the code.
This feature request seems to fall in the area beyond reformatting. Eventually, we might open the project to this kind of code transformation, but we're not there yet.