js-beautify icon indicating copy to clipboard operation
js-beautify copied to clipboard

Feature request: strip keys with default json values

Open nachowski opened this issue 5 years ago • 2 comments

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

nachowski avatar Sep 05 '19 12:09 nachowski

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 avatar Apr 11 '22 17:04 a-vento

@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.

bitwiseman avatar Apr 12 '22 05:04 bitwiseman