Skip to content

In v7.4, Test-Json no longer accepts nonstandard JSON extensions, such as single quotes, barewords, and comments #10950

Closed
@mklement0

Description

@mklement0

Type of issue

Outdated article

Feedback

  • Test-Json was switched to using System.Text.Json to improve JSON schema support, in PR #18141, which took effect in v7.4.0.

  • This introduced a problematic asymmetry, in that Test-Json now no longer accepts nonstandard JSON (single quotes, barewords, comments), whereas the NewtonSoft.Json-based ConvertFrom-Json does; e..g,
    '{ foo: 1 }' | ConvertFrom-Json succeeds (property name is bareword), whereas
    '{ foo: 1 }' | Test-Json now fails.

  • For details, see Breaking Change: JSONC no longer works after 7.4.0 PowerShell/PowerShell#20782 (comment).

Note that this massive breaking change was likely unintentional, and at this point there's been no official feedback as to whether the old behavior will (also) be restored.


Therefore:

  • The page should state that only strictly conformant JSON is now being recognized as valid by Test-Json
  • The examples should be updated accordingly; e.g., "{'name': 'Ashley', 'age': 25}" | Test-Json no longer passes, due to the use of single quotes.

Page URL

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/test-json?view=powershell-7.4&viewFallbackFrom=powershell-7

Content source URL

https://github.com/MicrosoftDocs/PowerShell-Docs/blob/main/reference/7.4/Microsoft.PowerShell.Utility/Test-Json.md

Author

@sdwheeler

Document Id

2916f68d-0849-3302-7422-918f748aa6d4

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