Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Newtonsoft.Json.Schema.JsonSchema是否已过时?_C#_.net_Json_Json.net - Fatal编程技术网

C# Newtonsoft.Json.Schema.JsonSchema是否已过时?

C# Newtonsoft.Json.Schema.JsonSchema是否已过时?,c#,.net,json,json.net,C#,.net,Json,Json.net,我尝试创建一个方法,使用以下方法验证Json字符串和Json模式: 它说该对象已过时,并已移动到其自己的包中,因此我使用NuGet并安装该包(Newtonsoft.Json.dll和Newtonsoft.Json.Schema.dll是引用),并具有: using Newtonsoft.Json.Schema; using Newtonsoft.Json.Linq; public bool validateSchema(string _Json) { JsonS

我尝试创建一个方法,使用以下方法验证Json字符串和Json模式:

它说该对象已过时,并已移动到其自己的包中,因此我使用
NuGet
并安装该包(
Newtonsoft.Json.dll
Newtonsoft.Json.Schema.dll
是引用),并具有:

using Newtonsoft.Json.Schema;
using Newtonsoft.Json.Linq;

    public bool validateSchema(string _Json)
    {
        JsonSchema schema = JsonSchema.Parse(
                        @"{
                            'properties': {
                                [MySchemaHere]
                        }
                        ");
        JObject jobject = JObject.Parse(_Json);

        return jobject.IsValid(schema);
    }
我如何摆脱过时的信息?在我看来,这段代码好像已经被移到了另一个包/dll,但调用/使用的方式是相同的,我不知怎么引用了那个过时的包?这似乎是我遗漏了一些简单/明显的东西

编辑:这里有一张图片可能会有所帮助


你确定你有这个dll吗,您的问题似乎是此JSON模式验证已移动到其自己的包中,请在此处查看更多信息:


希望这些帮助

我终于创建了一个新项目并复制/粘贴了他们的示例,我看到了我一直在努力克服的明显错误

我应该使用:

杰切马

不是

JsonSchema


在搜索“JSON.net schema”后添加了一个新的NuGet包,结果在选项中显示了另一个Newtonsoft.JSON.schema包,解决了我的问题:

工具>Nuget软件包管理器>管理解决方案的Nuget软件包

执行此操作后,将JSONSchema对象更改为JSchema对象。这将删除过时的消息,并正确编译代码

之后:

string schemaJson = @"{
  'description': 'A person',
  'type': 'object',
  'properties':
  {
    'name': {'type':'string'},
    'hobbies': {
      'type': 'array',
      'items': {'type':'string'}
    }
  }
}";
更改:

            JsonSchema schema = JsonSchema.Parse(schemaJson); 


我刚刚编辑了我的答案,添加了一张图片。据我所知,DLL添加正确,是吗?是@BrianRogers,拼写错误。它应该是编译的:)经过3-4天的马戏表演,最后这个答案给出了结果;甘尼什酒店
            JSchema schema = JSchema.Parse(schemaJson);