You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
convertfrom-yaml does not preserve single-element arrays.
Example:
# Create a hash with two key-value pairs. Both values are arrays, but one of them
# has just a single element
$j = [ordered]@{
apac = @('Australia')
emea = @('Italy', 'Finland')
}
#Confirm that both values are arrays
PS C:\> $j.apac.gettype().name
Object[]
PS C:\> $j.emea.gettype().name
Object[]
# Convert to yaml. Good so far, we still have two arrays/sequences.
PS C:\> $j | convertto-yaml
---
apac:
- 'Australia'
emea:
- 'Italy'
- 'Finland'
# Convert back to a PowerShell object and we lose one of the arrays.
# Now we have one array and one scalar. We should have two arrays.
PS C:\> $j = $j | convertto-yaml | convertfrom-yaml
PS C:\> $j.apac.gettype().name
String
PS C:\> $j.emea.gettype().name
Object[]
The text was updated successfully, but these errors were encountered:
vyrp
pushed a commit
to vyrp/PSYaml
that referenced
this issue
Dec 2, 2017
convertfrom-yaml does not preserve single-element arrays.
Example:
The text was updated successfully, but these errors were encountered: