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
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.
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.
Type of issue
Outdated article
Feedback
Test-Jsonwas switched to usingSystem.Text.Jsonto improve JSON schema support, in PR #18141, which took effect in v7.4.0.This introduced a problematic asymmetry, in that
Test-Jsonnow no longer accepts nonstandard JSON (single quotes, barewords, comments), whereas theNewtonSoft.Json-basedConvertFrom-Jsondoes; e..g,'{ foo: 1 }' | ConvertFrom-Jsonsucceeds (property name is bareword), whereas'{ foo: 1 }' | Test-Jsonnow 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:
Test-Json"{'name': 'Ashley', 'age': 25}" | Test-Jsonno 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