using System.Collections.Generic;
namespace ConsoleApplication_Json
{
public class RoomResponse
{
public string id { get; set; }
public string status { get; set; }
public string httpstatus { get; set; }
public List<Data> data { get; set; }
public string nextLink { get; set; }
}
public class Data
{
public Room room { get; set; }
public string address { get; set; }
public string sign { get; set; }
}
public class Room
{
public string field1 { get; set; }
public string field2 { get; set; }
public string field3 { get; set; }
public string field4 { get; set; }
public string field5 { get; set; }
public string field6 { get; set; }
}
}
.进入Program.cs 文件,编辑代码如下:
namespace ConsoleApplication_Json
{
class Program
{
static void Main(string[] args)
{
var strJson = "{\"id\":\"ko09895dd6g565d5222242125\",\"status\":true,\"httpstatus\":200,\"data\":[{\"room\":{\"field1\":\"955gg2015\",\"field2\":\"G1020\",\"field3\":\"VIP\",\"field4\":\"大包\",\"field5\":\"李春凤\",\"field6\":\"10086611\"},\"address\":\"这里是个地址信息\",\"sign\":\"预订\"},{\"room\":{\"field1\":\"955gg2016\",\"field2\":\"G1022\",\"field3\":\"VIP_null\",\"field4\":\"中等包\",\"field5\":\"李春凤\",\"field6\":\"10086622\"},\"address\":\"这里是个地址信洗第二个\",\"sign\":\"预订\"}],\"nextLink\":\"www.baidu.com\"}";
var test1 = JsonHelper.Json2Obj<RoomResponse>(strJson);
}
}
}