我正在构建一个小应用程序,它从我无法控制的API中提取统计信息.JSON字符串如下所示:
{
"weapons":
[
{
"aek":
{
"name":"AEK-971 Vintovka",
"kills":47,
"shots_fired":5406,
"shots_hit":858
},
"xm8":
{
"name":"XM8 Prototype",
"kills":133,
"shots_fired":10170,
"shots_hit":1790
},
}
]
}
Run Code Online (Sandbox Code Playgroud)
我的对象设置如下:
class WeapsCollection
{
public WeaponList[] Weapons { get; set; }
}
class WeaponList
{
public WeaponDetails AEK { get; set; }
public WeaponDetails XM8 { get; set; }
}
class WeaponDetails
{
public string Name { get; set; }
public int Kills { get; set; }
public int Shots_Fired { get; set; }
public int …Run Code Online (Sandbox Code Playgroud)