You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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-Jsonstill returns$true.I propose adding a
-Strictparameter toTest-Jsonfor testing that the JSON string adheres strictly to the JSON specification.Side note
I was very excited when I found the
Test-Jsoncmdlet, 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.