Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.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/4/json/13.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#JSON反序列化错误数组_C#_Json_Serialization - Fatal编程技术网

C#JSON反序列化错误数组

C#JSON反序列化错误数组,c#,json,serialization,C#,Json,Serialization,我是C语言的新手,我想在C语言中反序列化JSON对象,但我遇到了一个错误: 我们遇到了一个问题:无法反序列化当前JSON数组(例如。 [1,2,3])转换为类型“ZK4000_Example.JsonParser+user”,因为 需要一个JSON对象(例如{“name”:“value”})来反序列化 正确地要修复此错误,请将JSON更改为JSON对象 (例如{“name”:“value”})或将反序列化类型更改为数组或 实现集合接口的类型(例如ICollection、, IList)类似于可以

我是C语言的新手,我想在C语言中反序列化JSON对象,但我遇到了一个错误:

我们遇到了一个问题:无法反序列化当前JSON数组(例如。 [1,2,3])转换为类型“ZK4000_Example.JsonParser+user”,因为 需要一个JSON对象(例如{“name”:“value”})来反序列化 正确地要修复此错误,请将JSON更改为JSON对象 (例如{“name”:“value”})或将反序列化类型更改为数组或 实现集合接口的类型(例如ICollection、, IList)类似于可以从JSON数组反序列化的列表。 还可以将JsonArrayAttribute添加到类型中,以强制它 从JSON数组反序列化。路径“usuarios”,第1行,位置24

路径“”,第1行,位置1

我从其他有同样问题的用户那里读到了另一个解决方案,但我还不能解决它

我的Json:

{
  "estado": 1,
  "usuarios": [
    {
      "nombre": "as",
      "id_usuario": "34",
      "huella_string": "1"
    },
    {
      "nombre": "ded",
      "id_usuario": "35",
      "huella_string": "1"
    },
    {
      "nombre": "sa",
      "id_usuario": "36",
      "huella_string": "1"
    },
    {
      "nombre": "xz",
      "id_usuario": "12",
      "huella_string": "1"
    },
    {
      "nombre": "asas,
      "id_usuario": "28",
      "huella_string": "1"
    },
    {
      "nombre": "asscass",
      "id_usuario": "7",
      "huella_string": "mspZVoOalsE9QQsrwkQBBSS/PoEMo8BCAQmiLS/BC5YuKYEVicJIQQkTQlFBCxDES4EPFbE+wQI0UkqBDYW5KYEIKEs6QQmaTzYBEZEjGQEV7qxYAQaczhfBDeQaTEEGH8M0AQelrk0BDCVMK4EOlk8owRGHLTwBBqM8EUEd3CgQwQ/dCUSBAxrEJsEJpcgcATU3NT4BBK5ECgEEzpcJwQXloBIBD2UOIkELfJM4AQmKyFcBDI8QV8EDlU9ZAQ2GKl6BBhlWxJAFXdCyBwANWFxldQwbJCgpJiMjIiMADVZZZXYPICgsLCgkIiIjAAxcX2Z2DBghJSYlIyIiAA1WWWZ0FCMqLS0nIyMiJAAMYWNpdQkTHCEjIiAgHwANVltmAholKi0sJiMiIiUADGhpb3cHEBkdICAdHBwADFZcag0hKCssKSUhISEADGlscXcHDxYbHR0bGxoADFRYYBkkKiopJSIdHB0ADGtucncGDhUaHBsaGhsADVRXTCsoKigmIyAcGh0pAAxsb3MBCA8WGhsbGhscAAxUVU42KCYlIyEdGhccAAtwcnUCCRAWGhsaGhsADFdWUz0kIiIhIBwaFx0BC3V3BAkRFhkbGxscAAtXV1dfGhobGhoWEgwBCnYBBAkPFRobGxsADGxgXm4KERISEA0LCgsDCQQIDxUZHBwBC3FkbwULDQwLCAYE"
    }
  ],
  "peticion": "seleccion_usuarios"
}
这些是我的课程:

class JsonParser
    {
        public int estado { set; get; }
        public string peticion { set; get; }
        public user usuarios { set; get; }

        public  class user
        {
            public string id_usuario { set; get; }
            public string huella_string { set; get; }
            public string nombre { set; get; }
        }

    }
这就是我如何调用数组中的一个值

var Json = JsonConvert.DeserializeObject<JsonParser>(strJSON);
ShowHintInfo(Json.usuarios.id_usuario);
var Json=JsonConvert.DeserializeObject(strJSON);
ShowHintInfo(Json.usuarios.id\u usuario);
谢谢,非常简单。看

      "nombre": "asas,
你忘了最后的报价了。在以后检查任何其他内容之前,请使用确保您的JSON有效。

非常简单。看

      "nombre": "asas,

你忘了最后的报价了。在以后检查任何其他内容之前,请使用确保JSON有效。

usuarios
是一个数组。使用
user[]

class JsonParser
{
    public int estado { set; get; }
    public string peticion { set; get; }
    public user[] usuarios { set; get; }

    public  class user
    {
        public string id_usuario { set; get; }
        public string huella_string { set; get; }
        public string nombre { set; get; }
    }

}

usuarios
是一个数组。使用
user[]

class JsonParser
{
    public int estado { set; get; }
    public string peticion { set; get; }
    public user[] usuarios { set; get; }

    public  class user
    {
        public string id_usuario { set; get; }
        public string huella_string { set; get; }
        public string nombre { set; get; }
    }

}

打败我吧哈哈,我自己也被打败过很多次,这是一个数字游戏:)是的,阵列也有问题。刚才看到其他人已经回答了这个问题,这可能是他的JSON有问题,但不是错误消息的原因,所以即使他解决了这个问题,他也不会消除错误。谢谢,尽管我发布这个问题时有错,我更改了参数,因为有真名。打败我吧哈哈,我自己也被打败过很多次,这是一个数字游戏:)是的,数组也有问题。刚才看到其他人已经回答了这个问题,他的JSON可能有问题,但这不是错误消息的原因,所以即使他修复了这个问题,他也不会消除错误。谢谢,虽然我在发布问题时输入了一个错误,但我更改了参数,因为有真名。