Prerequisites
Steps to reproduce
Get to latest 7.4.0 (or preview) version of Powershell
Create schema.json file as follows:
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "http://lol.com/lol.json",
"type": "object",
"properties": {
"lol": {
"type": "integer"
},
"muth": {
"type":"boolean"
}
},
"required": [
"lol","muth"
],
"additionalProperties": false
}
Create a sample JSON file as follows:
{
"lol": 4,
"muth": false
}
Expected behavior
PS> Get-Content .\the.json -Raw | Test-Json -SchemaFile .\schema.json
True
Actual behavior
PS C:\Temp\toto> Get-Content .\the.json -Raw | Test-Json -SchemaFile .\schema.json
Test-Json: Cannot parse the JSON.
False
Error details
Exception :
Type : System.Exception
Message : Cannot parse the JSON.
InnerException :
Type : Json.Schema.JsonSchemaException
TargetSite :
Name : DetermineSpecVersion
DeclaringType : Json.Schema.JsonSchema
MemberType : Method
Module : JsonSchema.Net.dll
Message : Custom meta-schema `$schema` keywords must eventually resolve to a meta-schema for a supported
specification version.
Source : JsonSchema.Net
HResult : -2146233088
StackTrace :
at Json.Schema.JsonSchema.DetermineSpecVersion(JsonSchema schema, SchemaRegistry registry, SpecVersion desiredDraft)
at Json.Schema.JsonSchema.Evaluate(JsonNode root, EvaluationOptions options)
at Microsoft.PowerShell.Commands.TestJsonCommand.ProcessRecord()
HResult : -2146233088
TargetObject : {
"lol": 4,
"muth": false
} CategoryInfo : InvalidData: ({ "lol": 4, "muth": false } :String) [Test-Json], Exception FullyQualifiedErrorId : InvalidJson,Microsoft.PowerShell.Commands.TestJsonCommand InvocationInfo : MyCommand : Test-Json ScriptLineNumber : 1 OffsetInLine : 31 HistoryId : 11 Line : Get-Content .\the.json -Raw | Test-Json -SchemaFile .\schema.json Statement : Test-Json -SchemaFile .\schema.json PositionMessage : At line:1 char:31 + Get-Content .\the.json -Raw | Test-Json -SchemaFile .\schema.json + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ InvocationName : Test-Json CommandOrigin : Internal ScriptStackTrace : at <ScriptBlock>, <No file>: line 1 PipelineIterationInfo :
Environment data
$PSVersionTable
Name Value
---- -----
PSVersion 7.4.0-rc.1
PSEdition Core
GitCommitId 7.4.0-rc.1
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Prerequisites
Steps to reproduce
Get to latest 7.4.0 (or preview) version of Powershell
Create
schema.jsonfile as follows:{ "$schema": "http://json-schema.org/draft-07/schema", "$id": "http://lol.com/lol.json", "type": "object", "properties": { "lol": { "type": "integer" }, "muth": { "type":"boolean" } }, "required": [ "lol","muth" ], "additionalProperties": false }Create a sample JSON file as follows:
{ "lol": 4, "muth": false }Expected behavior
Actual behavior
Error details
Environment data
Visuals
No response