C# 验证JsonSchema在Json.NET中是否包含有效的架构

C# 验证JsonSchema在Json.NET中是否包含有效的架构,c#,.net,json,json.net,jsonschema,C#,.net,Json,Json.net,Jsonschema,我试图检测JsonSchema是否包含有效的模式。据我所知,Json.NET没有验证Json模式的方法 您似乎可以使用完全无效的模式创建JsonSchema,它不会抱怨,如下所示: var invalidSchema = JsonSchema.Parse(@"{ ""title"": { ""Invalid"": ""Invalid"" } }"); 然后,您可以继续根据无效的模式验证JObjects,并返回true。作为记录,根据已发布的自我描述模式(我已检查),上述“模式”无效 我试着解析

我试图检测JsonSchema是否包含有效的模式。据我所知,Json.NET没有验证Json模式的方法

您似乎可以使用完全无效的模式创建JsonSchema,它不会抱怨,如下所示:

var invalidSchema = JsonSchema.Parse(@"{ ""title"": { ""Invalid"": ""Invalid"" } }");
然后,您可以继续根据无效的模式验证JObjects,并返回true。作为记录,根据已发布的自我描述模式(我已检查),上述“模式”无效

我试着解析这个函数来验证其他的模式,但是我没有做太多。当我尝试解析它时,会出现异常:

Newtonsoft.Json.JsonReaderException was unhandled by user code
  HResult=-2146233088
  Message=Exception JSON schema type string token, got StartObject. Path 'properties.type.items.type[1]', line 11, position 6.
  Source=Newtonsoft.Json
  LineNumber=11
  LinePosition=6
  Path=properties.type.items.type[1]
  StackTrace:
       at Newtonsoft.Json.Schema.JsonSchemaBuilder.ProcessType()
       at Newtonsoft.Json.Schema.JsonSchemaBuilder.ProcessSchemaProperty(String propertyName)
       at Newtonsoft.Json.Schema.JsonSchemaBuilder.BuildSchema()
       at Newtonsoft.Json.Schema.JsonSchemaBuilder.ProcessItems()
       at Newtonsoft.Json.Schema.JsonSchemaBuilder.ProcessSchemaProperty(String propertyName)
       at Newtonsoft.Json.Schema.JsonSchemaBuilder.BuildSchema()
       at Newtonsoft.Json.Schema.JsonSchemaBuilder.ProcessProperties()
       at Newtonsoft.Json.Schema.JsonSchemaBuilder.ProcessSchemaProperty(String propertyName)
       at Newtonsoft.Json.Schema.JsonSchemaBuilder.BuildSchema()
       at Newtonsoft.Json.Schema.JsonSchemaBuilder.Parse(JsonReader reader)
       at Newtonsoft.Json.Schema.JsonSchema.Read(JsonReader reader, JsonSchemaResolver resolver)
       at Newtonsoft.Json.Schema.JsonSchema.Parse(String json, JsonSchemaResolver resolver)
       at Newtonsoft.Json.Schema.JsonSchema.Parse(String json)
  InnerException: