Skip to content

ConvertFrom-Json doesn't unwrap arrays on output, resulting in an extraneous wrapper JSON object with Count and Value properties on reconversion #3153

@mklement0

Description

@mklement0

Steps to reproduce

'[ 1, 2 ]' | ConvertFrom-Json | ConvertTo-Json

Expected behavior

[
    1,
    2
]

Actual behavior

{
    "value":  [
                  1,
                  2
              ],
    "Count":  2
}

I believe the root cause is that ConvertFrom-Json sends arrays as a whole through the pipeline instead of unwrapping them.

Analysis, more examples, and workaround here: http://stackoverflow.com/a/38212718/45375

Environment data

PowerShell v6.0.0-alpha (v6.0.0-alpha.15) on Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64
PowerShell v5.1.14393.693 on Microsoft Windows 10 Pro (64-bit; v10.0.14393)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-FixedThe issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions