Skip to content

Bug when converting from JSON and Powershell lists to YAML since version 0.4.8 #185

@maritnl

Description

@maritnl

When using ConvertFrom-Yaml on a powershell or JSON object of type list, the YAML output is a list of the length of each string value instead of the actual values since version 0.4.8. It was last working properly in version 0.4.7.

Install-Module powershell-yaml -MinimumVersion 0.4.8

echo "yamlList: []" > myfile.yaml

$file = Get-Content "./myfile.yaml" 

$jsonlist = '[
    "item1",
    "item2"
]'

$file_json = $file | ConvertFrom-Yaml | ConvertTo-JSON -Depth 3 | ConvertFrom-Json
$file_json.yamlList = $jsonlist | ConvertFrom-Json
$file_json | ConvertTo-Yaml | Out-File "./outfile.yaml"

cat ./outfile.yaml

Expected output: (correct in version 0.4.7 and earlier)

yamlList:
- item1
- item2

Actual output: (since version 0.4.8)

yamlList:
- Length: 5
- Length: 5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions