16,552
社区成员
发帖
与我相关
我的任务
分享
public class List
{
public int c_t { get; set; }
public string c_d { get; set; }
public string c_r { get; set; }
public List<object> o_m { get; set; }
}
public class RootObject
{
public int s { get; set; }
public string m { get; set; }
public string c { get; set; }
public int l_c { get; set; }
public int l_t { get; set; }
public string l_d { get; set; }
public string l_r { get; set; }
public int c_t { get; set; }
public string c_d { get; set; }
public int n_t { get; set; }
public string n_d { get; set; }
public List<List> list { get; set; }
public int no { get; set; }
public string o_info { get; set; }
public string o_info_t { get; set; }
public int o_g { get; set; }
public int os { get; set; }
public string osm { get; set; }
}
var json = new System.Net.WebClient() { Encoding = System.Text.Encoding.UTF8 }.DownloadString("http://www.1680180.com/Open/CurrentOpen?code=10016");
var 对象 = Newtonsoft.Json.JsonConvert.DeserializeObject<RootObject>(json);
对象.list.ForEach(item => {
Response.Write(item.c_d+"<br>");
});
{
"s": 0,
"m": "",
"c": "10016",
"l_c": 42,
"l_t": 597172,
"l_d": "2017/01/12 12:33:03",
"l_r": "4,1,6,10,5,2,8,9,7,3",
"c_t": 597172,
"c_d": "2017/01/12 12:31:00",
"n_t": 597173,
"n_d": "2017/01/12 12:37:43",
"list": [
{
"c_t": 597172,
"c_d": "01/12 [周四] 12:31:00",
"c_r": "4,1,6,10,5,2,8,9,7,3",
"o_m": [
5,
"小",
"单",
"龙",
"虎",
"虎",
"龙",
"龙"
]
},
{
"c_t": 597171,
"c_d": "01/12 [周四] 12:26:00",
"c_r": "10,5,4,1,2,6,7,3,9,8",
"o_m": [
15,
"大",
"单",
"龙",
"虎",
"龙",
"虎",
"虎"
]
},
{
"c_t": 597170,
"c_d": "01/12 [周四] 12:21:00",
"c_r": "4,1,10,9,5,8,2,7,6,3",
"o_m": [
5,
"小",
"单",
"龙",
"虎",
"龙",
"龙",
"虎"
]
},
{
"c_t": 597169,
"c_d": "01/12 [周四] 12:16:00",
"c_r": "6,1,10,5,4,9,3,2,8,7",
"o_m": [
7,
"小",
"单",
"虎",
"虎",
"龙",
"龙",
"虎"
]
},
{
"c_t": 597168,
"c_d": "01/12 [周四] 12:11:00",
"c_r": "6,7,3,5,9,8,1,2,4,10",
"o_m": [
13,
"大",
"单",
"虎",
"龙",
"龙",
"龙",
"龙"
]
},
{
"c_t": 597167,
"c_d": "01/12 [周四] 12:06:00",
"c_r": "5,6,1,7,9,3,8,4,10,2",
"o_m": [
11,
"小",
"单",
"龙",
"虎",
"虎",
"虎",
"龙"
]
},
{
"c_t": 597166,
"c_d": "01/12 [周四] 12:01:00",
"c_r": "5,8,1,3,10,9,6,7,2,4",
"o_m": [
13,
"大",
"单",
"龙",
"龙",
"虎",
"虎",
"龙"
]
},
{
"c_t": 597165,
"c_d": "01/12 [周四] 11:56:00",
"c_r": "7,9,6,3,2,1,8,10,5,4",
"o_m": [
16,
"大",
"双",
"龙",
"龙",
"虎",
"虎",
"龙"
]
},
{
"c_t": 597164,
"c_d": "01/12 [周四] 11:51:00",
"c_r": "9,2,5,7,10,8,1,6,4,3",
"o_m": [
11,
"小",
"单",
"龙",
"虎",
"虎",
"龙",
"龙"
]
},
{
"c_t": 597163,
"c_d": "01/12 [周四] 11:46:00",
"c_r": "5,6,2,1,9,8,3,4,10,7",
"o_m": [
11,
"小",
"单",
"虎",
"虎",
"虎",
"虎",
"龙"
]
}
],
"no": 179,
"o_info": "每5分钟",
"o_info_t": "9:06:00",
"o_g": 100,
"os": 0,
"osm": "暂停开奖"
}
那么根据json转换对象的网站http://json2csharp.com/#.得到如下
public class List
{
public int c_t { get; set; }
public string c_d { get; set; }
public string c_r { get; set; }
public List<object> o_m { get; set; }
}
public class RootObject
{
public int s { get; set; }
public string m { get; set; }
public string c { get; set; }
public int l_c { get; set; }
public int l_t { get; set; }
public string l_d { get; set; }
public string l_r { get; set; }
public int c_t { get; set; }
public string c_d { get; set; }
public int n_t { get; set; }
public string n_d { get; set; }
public List<List> list { get; set; }
public int no { get; set; }
public string o_info { get; set; }
public string o_info_t { get; set; }
public int o_g { get; set; }
public int os { get; set; }
public string osm { get; set; }
}
然后在根据Newtonsoft.JSON来"反序列化"
var 对象=Newtonsoft.Json.JsonConvert.DeserializeObject<RootObject>(result);
over.
然后你对象点属性. 以及点集合 就都可以使用了