Skip to content

ConvertFrom-Json includes $null element on output if input starts with blank line #12229

@krishnayalavarthi

Description

@krishnayalavarthi

Steps to reproduce

PS D:\> @('{"common":[1,2]}' | ConvertFrom-Json).Length
PS D:\> @('','{"common":[1,2]}' | ConvertFrom-Json).Length
PS D:\> @('','','{"common":[1,2]}' | ConvertFrom-Json).Length
PS D:\> @('{"common":','[1,2]}' | ConvertFrom-Json).Count

Expected behavior

PS D:\> @('{"common":[1,2]}' | ConvertFrom-Json).Length
1

PS D:\> @('','{"common":[1,2]}' | ConvertFrom-Json).Length
1

PS D:\> @('','','{"common":[1,2]}' | ConvertFrom-Json).Length
1

PS D:\> @('{"common":','[1,2]}' | ConvertFrom-Json).Count
1

Actual behavior

PS D:\> @('{"common":[1,2]}' | ConvertFrom-Json).Length
1

PS D:\> @('','{"common":[1,2]}' | ConvertFrom-Json).Length
2

PS D:\> @('','','{"common":[1,2]}' | ConvertFrom-Json).Length
2

PS D:\> @('{"common":','[1,2]}' | ConvertFrom-Json).Count
1

Environment data


Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions