//Then
client.AddCommand("INFODENSUS88", async (x) =>
{
string html = await new WebClient().DownloadStringTaskAsync("https://www.erevollution.com/en/api/military-unit/177");
//output html is working fine
using (var sr = new StringReader(html))
using (var jr = new JsonTextReader(sr))
{
var js = new JsonSerializer();
var u = js.Deserialize<RootObject>(jr);
Console.WriteLine(u.CommanderName);
await x.Message.Parent.SendMessage(u.CommanderName);
}
//output u.commandername = NULL
});
OUTPUT = NULL
当我启动程序时,没有任何输出/ NULL T_T有人帮帮我。
答案 0 :(得分:0)
Html返回JSON数组,并且您尝试转换为单个对象,在代码中进行以下更改:
Table 1 test table
这里我只返回数组中第一个对象的CommanderName。