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

Single-element arrays are not preserved #13

Open
cp880 opened this issue Sep 11, 2017 · 0 comments
Open

Single-element arrays are not preserved #13

cp880 opened this issue Sep 11, 2017 · 0 comments

Comments

@cp880
Copy link

cp880 commented Sep 11, 2017

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[]
vyrp pushed a commit to vyrp/PSYaml that referenced this issue Dec 2, 2017
vyrp added a commit to vyrp/PSYaml that referenced this issue Dec 2, 2017
Phil-Factor added a commit that referenced this issue Dec 2, 2017
Fix issue #13 'Single-element arrays are not preserved'
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

No branches or pull requests

1 participant