Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add graph visitor that ignores null values #137

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

gabriel-samfira
Copy link
Member

@gabriel-samfira gabriel-samfira commented Aug 26, 2024

When serializing to yaml, a new -Options OmitNullValues options will skip any mapping that has a null value.

Example:

PS /home/gabriel/powershell-yaml> import-module ./powershell-yaml.psd1
PS /home/gabriel/powershell-yaml> $testObj = @{"a"=1; "b"=$null; "c"="aa"}
PS /home/gabriel/powershell-yaml> ConvertTo-Yaml $testObj                                                                                  
b: 
a: 1
c: aa

PS /home/gabriel/powershell-yaml> ConvertTo-Yaml $testObj -Options OmitNullValues
a: 1
c: aa

PS /home/gabriel/powershell-yaml> 

Fixes: #129

When serializing to yaml, a new -OmitNullValues options will skip any
mapping that has a null value.

Signed-off-by: Gabriel Adrian Samfira <[email protected]>
@gabriel-samfira gabriel-samfira merged commit 0d5b89f into cloudbase:master Aug 26, 2024
7 checks passed
@gabriel-samfira gabriel-samfira deleted the omit-null-values branch August 26, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SerializationOptions enum value SupressNullValuedProperties / enable the option to not output null values
1 participant