Skip to content

ConvertFrom-Json: comments in top-level arrays are parsed incorrectly (but also are not errors) #14553

@aslatter

Description

@aslatter

According to #7436 ConvertFrom-Json should support "JSONC"-style comments present in JSON objects without issue.

However this doesn't seem to work if the comments are in a "top level" array - instead the comments are interpreted as strings-elements within the array.

Steps to reproduce

ConvertFrom-Json -NoEnumerate "[`n// foo`n 100, `n /* bar */`n 200]" | ConvertTo-Json -Compress

Expected behavior

Either an error (due to comments not being supported) or:

[100,200]

Actual behavior

[" foo",100," bar ",200]

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.0-preview.2
PSEdition                      Core
GitCommitId                    7.2.0-preview.2
OS                             Linux 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

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

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions