我想把它变成一个类,这样我就可以解析它…但是http://json2csharp.com/给它一个错误。。我想我可以自己做,但像"红队"one_answers"禁令名称"这样的变量的名称中都有空格。。这样我就完全放弃了
还有一个事实是,有一个"红队"和一个"蓝队"有点让我感到困惑,因为我在互联网上看到的例子在一个文件中没有两个不同的类。。有人能帮上忙吗?试图学习JSON.net,但在解析所有时遇到问题
{
"red team": {
"ban name": [
"Corkii",
"Darius",
"Diana"
],
"ban number": [
14,
15,
16
],
"players": [
"Nien",
"bigfatlp",
"Link",
"Doublelift",
"Chauster"
],
"pick rate": [
0.7,
0.5,
0.8,
0.9,
0.6
],
"pick number": [
6,
7,
8,
9,
10
],
"team": "Counter Logic Gaming",
"pick name": [
"Anivia",
"Annie",
"Ashe",
"Blitzcrank",
"Brand"
],
"pick win rate": [
0.6,
0.7,
0.8,
0.9,
0.5
]
},
"blue team": {
"ban name": [
"Caitlyn",
"Cassiopeia",
"Chogath"
],
"ban number": [
11,
12,
13
],
"players": [
"Dyrus",
"TheOddOne",
"Reginald",
"WildTurtle",
"Xpecial"
],
"pick rate": [
0.2,
0.5,
0.3,
0.4,
0.1
],
"pick number": [
1,
2,
3,
4,
5
],
"team": "TSM Snapdragon",
"pick name": [
"Aatrox",
"Ahri",
"Akali",
"Alistar",
"Amumu"
],
"pick win rate": [
0.1,
0.2,
0.3,
0.4,
0.5
]
}
使用JSONLint检查您的JSON,我得到:
Parse error on line 1:
"redteam": { "ba
^
Expecting '{', '['
您必须以{开始JSON,并以相应的}结束JSON。如果您添加这些字符,并允许JSONLint删除多余的空格,您将得到以下内容:
public class Redteam
{
public List<string> banname { get; set; }
public List<int> bannumber { get; set; }
public List<string> players { get; set; }
public List<double> pickrate { get; set; }
public List<int> picknumber { get; set; }
public string team { get; set; }
public List<string> pickname { get; set; }
public List<double> pickwinrate { get; set; }
}
public class Blueteam
{
public List<string> banname { get; set; }
public List<int> bannumber { get; set; }
public List<string> players { get; set; }
public List<double> pickrate { get; set; }
public List<int> picknumber { get; set; }
public string team { get; set; }
public List<string> pickname { get; set; }
public List<double> pickwinrate { get; set; }
}
public class RootObject
{
public Redteam redteam { get; set; }
public Blueteam blueteam { get; set; }
}