有没有办法将JSON内容反序列化为C#4动态类型?为了使用DataContractJsonSerializer,跳过创建一堆类会很不错.
我正在尝试使用RIOT API为英雄联盟制作一个UWP应用程序.
当我去他们的网站生成JSON我得到这样的东西:
{"gigaxel": {
"id": 36588106,
"name": "Gigaxel",
"profileIconId": 713,
"revisionDate": 1451577643000,
"summonerLevel": 30
}}
Run Code Online (Sandbox Code Playgroud)
当我选择此JSON并使用Visual Studio 2015中的特殊粘贴方法将其复制到新类时,我将获得具有以下属性的这些类:
public class Rootobject
{
public Gigaxel gigaxel { get; set; }
}
public class Gigaxel
{
public int id { get; set; }
public string name { get; set; }
public int profileIconId { get; set; }
public long revisionDate { get; set; }
public int summonerLevel { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个名为LOLFacade连接到RiotAPI 的新类:
public class LOLFacade
{
private …Run Code Online (Sandbox Code Playgroud)