尝试反序列化RestSharp结果集。浏览网络以查找无济于事的示例。
Here are the results from deserial code I have now. 请注意,第一组对象为空。
这是我的代码的主体:
using RestSharp;
using RestSharp.Deserializers;
using System;
using System.Collections.Generic;
...
static void Main(string[] args)
{
var client = new RestClient("http://services.groupkt.com/country/get/all");
var request = new RestRequest("demo/jsondbcount.php", Method.GET)
{
RequestFormat = DataFormat.Json
};
IRestResponse<result> restResponse2 = client.Execute<result>(new RestRequest(Method.GET));
Console.WriteLine("content " + restResponse2.Content);
////The stuff below does not work.
JsonDeserializer deserializer = new JsonDeserializer();
List<result> x = deserializer.Deserialize<List<result>>(restResponse2);
foreach (result item in x)
{
Console.WriteLine("Show: {0}, release date: {1}", x,x);
}
这是我的成绩课
public class result
{
private string _alpha2_code;
private string _alpha3_code;
public string name { get; set; }
public string alpha2_code { get => _alpha2_code; set => _alpha2_code = value; }
public string alpha3_code { get => _alpha3_code; set => _alpha3_code = value; }
}
public class CityCodesDTO : List<result> { }
}
预先感谢您!