Skip to content

ConvertFrom-Json and Test-Json accept non-compliant/non-standard JSON - no way to strictly validate JSON #10628

@chriskuech

Description

@chriskuech

Summary of the new feature/enhancement

There does not seem to be any way to validate whether a JSON string is valid, which makes it impossible to use PowerShell to validate JSON before passing it to another application.

For example, the following JSON is invalid due to the trailing comma, but Test-Json still returns $true.

'{"hello": "world",}' | Test-Json

I propose adding a -Strict parameter to Test-Json for testing that the JSON string adheres strictly to the JSON specification.

Side note

I was very excited when I found the Test-Json cmdlet, but so far every use case it would have helped, it has not behaved as expected. See also #9560. If this cannot be implemented using the current library, please strongly consider using Json.NET instead of NJsonSchema.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility moduleWaiting - DotNetCorewaiting on a fix/change in .NET

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions