vb.net 解析json数据问题,R M B 答谢

tulip811226 2017-01-11 11:44:07
http://www.1680180.com/Open/CurrentOpen?code=10016
我想解析这个链接里的数据并且抓取这里面的数据,然后将这些数据存入一个数组中,
数组单个元素结构:
{
"c_t": 字符串,
"c_d": 字符串,
"c_r": 字符串,
"o_m": 字符串,
}
然后将数据用linq 的方式抓取并存入这个数组中,请高手帮忙。
谢谢,事成之后,20 R.M.B 支 付 宝转账!
源码请用vb.net,我想学习vb.net中使用Newtonsoft.JSON 和linq解析json的方法,再次感谢
...全文
665 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
拜一刀 2017-03-16
  • 打赏
  • 举报
回复
http://www.developerfusion.com/tools/convert/csharp-to-vb/
x287634334 2017-03-16
  • 打赏
  • 举报
回复
有C#代码就等于有VB.net代码了,网上有几个代码转换网页做的还是不错的。 搜索一下“C#转VB.net”。
tulip811226 2017-01-16
  • 打赏
  • 举报
回复
Re:diaodiaop 您好,可以写出vb.net 可用的代码吗?
by_封爱 2017-01-12
  • 打赏
  • 举报
回复
看数据结果 这不是六合彩么 1-49那种?
by_封爱 2017-01-12
  • 打赏
  • 举报
回复
完整代码 就是.

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>");
            });
by_封爱 2017-01-12
  • 打赏
  • 举报
回复
首先根据你网站http://www.1680180.com/Open/CurrentOpen?code=10016的地址 得到的数据如下

{
    "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. 然后你对象点属性. 以及点集合 就都可以使用了
EnForGrass 2017-01-12
  • 打赏
  • 举报
回复
你都知道用Newtonsoft.JSON去解析json了,还不知道怎么用 看官方文档啊http://www.newtonsoft.com/json 有LINQ 操作Json http://www.newtonsoft.com/json/help/html/Introduction.htm

16,552

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧