cloudbase / powershell-yaml

PowerShell CmdLets for YAML format manipulation
Apache License 2.0
434 stars 78 forks source link

Add `SerializationOptions` enum value `SupressNullValuedProperties` / enable the option to not output null values #129

Closed JohnLBevan closed 3 months ago

JohnLBevan commented 4 months ago

Today I can run @{one=1;two=$null} | ConvertTo-Yaml producing the below output:

one: 1
two:

It would be good to have the ability to prevent the output of fields with null values, so callers can choose to toggle this behaviour where their inputs contain properties with null values instead of simply not containing those properties.

Desired behaviour: @{one=1;two=$null} | ConvertTo-Yaml -Options SupressNullValuedProperties would produce the output:

one: 1
gabriel-samfira commented 3 months ago

Hi @JohnLBevan

I opened a PR here:

Is this what you had in mind?

JohnLBevan commented 3 months ago

That's awesome / exactly what I was after; thank-you @gabriel-samfira