我试图反序列化使用Newtonsoft这样我就可以在列表框中显示从基于云的服务器文件的数组,但我总是最后收到此错误无论怎样我尝试:C#Newtonsoft反序列化JSON阵列
Newtonsoft.Json.JsonReaderException:'解析值时遇到意外的字符:[。路径'[0] .priv',第4行,位置15。
THISIS一个例子尝试反序列化:
[
{
"code": 200,
"priv": [
{
"file": "file.txt",
"ext": "txt",
"size": "104.86"
},
{
"file": "file2.exe",
"ext": "exe",
"size": "173.74"
},
],
"pub": [
{
"file": "file.txt",
"ext": "txt",
"size": "104.86"
},
{
"file": "file2.exe",
"ext": "exe",
"size": "173.74"
}
]
}
]
我试图用C#类是这样的:
public class ListJson
{
[JsonProperty("pub")]
public List List { get; set; }
}
public class List
{
[JsonProperty("file")]
public string File { get; set; }
[JsonProperty("ext")]
public string Ext { get; set; }
[JsonProperty("size")]
public string Size { get; set; }
}
[JsonProperty("priv")]
public List List { get; set; }
}
public class List
{
[JsonProperty("file")]
public string File { get; set; }
[JsonProperty("ext")]
public string Ext { get; set; }
[JsonProperty("size")]
public string Size { get; set; }
}
并与反序列化:
List<list> fetch = Newtonsoft.Json.JsonConvert.DeserializeObject<List<list>>(json);
你用这个来验证你的[JSON](http://json.parser.online.fr/)*提示*它有一个语法错误 – t0mm13b
这不是我的json我从服务器的API中获得它所以我没有办法做到这一点:/我会告诉网站 – Zeq
的所有者,你有2个名为'List'的类?...? –