http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 8648|回复: 6

[咨询站长] 像下面这种4 5层的嵌套超复杂JSON格式怎么解析好些啦

[复制链接]
发表于 2015-9-2 11:48:37 | 显示全部楼层 |阅读模式
1金钱
本帖最后由 pyengwoei 于 2015-9-2 11:51 编辑

[C#] 纯文本查看 复制代码
{"u":null,"l":null,"n":[[3,"Baseball",[[244,"Mexican League",[[493207024,"Tigres de Quintana Roo","Leones de Yucatán",1,1441242000000,0,0,1,{"0":[[[1.5,-1.5,"1.5","2.530","1.552",1,0,221881479,0]],[["8.5",8.5,"1.925","1.925",221881479,0]],["2.220","1.699",null,221881479,0],0,null,1,0],"1":[[[0.0,0.0,"0.0","1.704","2.210",0,0,221881511,0]],[["4.5",4.5,"1.909","1.943",221881511,0]],null,1,null,0,0]},null,null,[1,0],1,null,null,null,null,"I",0,0,0,6],[493207030,"Toros de Tijuana","Acereros de Monclova",1,1441245900000,0,0,1,{"0":[[[-1.5,1.5,"1.5","1.591","2.440",0,1,221929688,0]],[["8.5",8.5,"1.869","1.990",221929688,0]],["1.877","1.980",null,221929688,0],0,null,0,0],"1":[[[0.0,0.0,"0.0","1.961","1.884",0,0,221929689,0]],[["4.5",4.5,"1.819","2.040",221929689,0]],null,1,null,0,0]},null,null,[1,0],1,null,null,null,null,"I",0,0,0,6]],null],[246,"MLB",[[494905342,"Chicago Cubs(J. Hammel)","Cincinnati Reds(R. Iglesias)",1,1441218000000,0,0,0,{"0":[[],[],["2.460","1.632",null,221941646,0],0,null,0,0]},null,null,[1,0],1,"J. Hammel","R. Iglesias",null,null,"I",0,0,0,1],[494905360,"Oakland Athletics(S. Gray)","LAA Angels(A. Heaney)",5,1441222500000,0,0,3,{"0":[[[1.0,-1.0,"1.0","1.990","1.884",1,0,1743377814,1],[1.5,-1.5,"1.5","2.510","1.609",1,0,221941667,0],[2.0,-2.0,"2.0","3.030","1.434",1,0,1743377812,1]],[["7.0",7.0,"1.952","1.952",221941667,0],["6.5",6.5,"1.719","2.250",1743377813,1],["7.5",7.5,"2.250","1.719",1743377815,1]],["2.350","1.684",null,221941667,0],0,null,1,0]},null,null,[1,0],1,"S. Gray","A. Heaney",null,null,"I",0,0,0,10],[494905364,"Boston Red Sox(H. Owens)","New York Yankees(M. Tanaka)",5,1441224300000,0,0,3,{"0":[[[-1.0,1.0,"1.0","1.961","1.909",0,1,1743378014,1],[-1.5,1.5,"1.5","1.757","2.220",0,1,221941683,0],[-2.0,2.0,"2.0","1.558","2.580",0,1,1743378012,1]],[["8.5",8.5,"1.862","2.050",221941683,0],["9.0",9.0,"2.060","1.819",1743378015,1],["8.0",8.0,"1.709","2.230",1743378013,1]],["1.714","2.290",null,221941683,0],0,null,0,0]},null,null,[1,0],1,"H. Owens","M. Tanaka",null,null,"I",0,0,0,10],[494905369,"Baltimore Orioles(K. Gausman)","Tampa Bay Rays(E. Ramirez)",5,1441235100000,0,0,3,{"0":[[[1.0,-1.0,"1.0","2.100","1.806",1,0,1743378110,1],[1.5,-1.5,"1.5","2.580","1.581",1,0,221941691,0],[2.0,-2.0,"2.0","3.120","1.413",1,0,1743378108,1]],[["8.5",8.5,"2.020","1.869",1743378111,1],["8.0",8.0,"1.869","2.040",221941691,0],["7.5",7.5,"1.740","2.200",1743378109,1]],["2.210","1.763",null,221941691,0],0,null,1,0]},null,null,[1,0],1,"K. Gausman","E. Ramirez",null,null,"I",0,0,0,10],[494905371,"Toronto Blue Jays(R. Dickey)","Cleveland Indians(T. Bauer)",5,1441235100000,0,0,3,{"0":[[[1.0,-1.0,"1.0","1.800","2.110",1,0,1743378358,1],[1.5,-1.5,"1.5","2.190","1.775",1,0,221941708,0],[2.0,-2.0,"2.0","2.560","1.568",1,0,1743378356,1]],[["9.0",9.0,"1.952","1.952",221941708,0],["8.5",8.5,"1.757","2.180",1743378357,1],["9.5",9.5,"2.180","1.757",1743378359,1]],["2.570","1.584",null,221941708,0],0,null,1,0]},null,null,[1,0],1,"R. Dickey","T. Bauer",null,null,"I",0,0,0,10],[494905345,"New York Mets(M. Harvey)","Philadelphia Phillies(A. Nola)",5,1441235400000,0,0,3,{"0":[[[1.5,-1.5,"1.5","1.961","1.961",1,0,221941888,0],[2.0,-2.0,"2.0","2.230","1.729",1,0,1743380572,1],[2.5,-2.5,"2.5","2.490","1.584",1,0,1743380570,1]],[["7.0",7.0,"2.000","1.909",221941888,0],["6.5",6.5,"1.751","2.200",1743380573,1],["7.5",7.5,"2.300","1.689",1743380575,1]],["3.270","1.401",null,221941888,0],0,null,1,0]},null,null,[1,0],1,"M. Harvey","A. Nola",null,null,"I",0,0,0,10],[494905376,"Houston Astros(S. Kazmir)","Seattle Mariners(T. Walker)",5,1441239000000,0,0,3,{"0":[[[1.0,-1.0,"1.0","1.877","2.000",1,0,1743374634,1],[1.5,-1.5,"1.5","2.350","1.684",1,0,221941449,0],[2.0,-2.0,"2.0","2.790","1.495",1,0,1743374632,1]],[["7.5",7.5,"1.952","1.952",221941449,0],["8.0",8.0,"2.110","1.793",1743374635,1],["7.0",7.0,"1.689","2.270",1743374633,1]],["2.490","1.617",null,221941449,0],0,null,1,0]},null,null,[1,0],1,"S. Kazmir","T. Walker",null,null,"I",0,0,0,10],[494905373,"Kansas City Royals(Y. Ventura)","Detroit Tigers(R. Wolf)",5,1441239000000,0,0,3,{"0":[[[1.5,-1.5,"1.5","2.160","1.793",1,0,221944970,0],[1.0,-1.0,"1.0","1.751","2.190",1,0,1743403922,1],[2.0,-2.0,"2.0","2.520","1.584",1,0,1743403920,1]],[["8.0",8.0,"1.917","1.990",221944970,0],["8.5",8.5,"2.070","1.833",1743403923,1],["7.5",7.5,"1.781","2.150",1743403921,1]],["2.660","1.552",null,221944970,0],0,null,1,0]},null,null,[1,0],1,"Y. Ventura","R. Wolf",null,null,"I",0,0,0,10],[494959719,"Milwaukee Brewers(Z.DAVIES)","Pittsburgh Pirates(J. Locke)",5,1441239000000,0,0,3,{"0":[[[-1.0,1.0,"1.0","1.970","1.900",0,1,1743378678,1],[-1.5,1.5,"1.5","1.751","2.230",0,1,221941733,0],[-2.0,2.0,"2.0","1.552","2.600",0,1,1743378676,1]],[["8.5",8.5,"1.952","1.952",221941733,0],["8.0",8.0,"1.793","2.110",1743378677,1],["9.0",9.0,"2.190","1.735",1743378679,1]],["1.714","2.290",null,221941733,0],0,null,0,0]},null,null,[1,0],1,"Z.DAVIES","J. Locke",null,null,"I",0,0,0,10],[494905378,"Minnesota Twins(T. Milone)","Chicago White Sox(C. Rodon)",5,1441239000000,0,0,3,{"0":[[[1.0,-1.0,"1.0","2.230","1.729",1,0,1743378774,1],[1.5,-1.5,"1.5","2.730","1.531",1,0,221941740,0],[2.0,-2.0,"2.0","3.330","1.375",1,0,1743378772,1]],[["8.0",8.0,"1.909","2.000",221941740,0],["8.5",8.5,"2.060","1.840",1743378775,1],["7.5",7.5,"1.769","2.160",1743378773,1]],["2.110","1.833",null,221941740,0],0,null,1,0]},null,null,[1,0],1,"T. Milone","C. Rodon",null,null,"I",0,0,0,10],[494905352,"St. Louis Cardinals(M. Wacha)","Washington Nationals(M. Scherzer)",4,1441239300000,0,0,1,{"0":[[[1.0,-1.0,"1.0","2.410","1.645",1,0,1743378574,1],[1.5,-1.5,"1.5","3.010","1.454",1,0,221941725,0],[2.0,-2.0,"2.0","3.760","1.311",1,0,1743378572,1]],[["6.5",6.5,"1.952","1.952",221941725,0]],["2.050","1.877",null,221941725,0],0,null,1,0]},null,null,[1,0],1,"M. Wacha","M. Scherzer",null,null,"I",0,0,0,6],[494905354,"Colorado Rockies(J. Gray)","Arizona Diamondbacks(C. Anderson)",5,1441240800000,0,0,3,{"0":[[[-1.0,1.0,"1.0","1.806","2.100",0,1,1743378878,1],[-1.5,1.5,"1.5","1.657","2.400",0,1,221941747,0],[-2.0,2.0,"2.0","1.502","2.760",0,1,1743378876,1]],[["11.0",11.0,"2.040","1.869",221941747,0],["10.5",10.5,"1.840","2.050",1743378877,1],["11.5",11.5,"2.240","1.719",1743378879,1]],["1.869","2.060",null,221941747,0],0,null,0,0]},null,null,[1,0],1,"J. Gray","C. Anderson",null,null,"I",0,0,0,10],[494905358,"Los Angeles Dodgers(C. Kershaw)","San Francisco Giants(M. Leake)",4,1441246200000,0,0,1,{"0":[[[1.5,-1.5,"1.5","2.020","1.909",1,0,221943044,0],[2.0,-2.0,"2.0","2.310","1.684",1,0,1743391568,1],[1.0,-1.0,"1.0","1.588","2.560",1,0,1743391570,1]],[["6.0",6.0,"2.040","1.869",221943044,0]],["3.190","1.416",null,221943044,0],0,null,1,0]},null,null,[1,0],1,"C. Kershaw","M. Leake",null,null,"I",0,0,0,6],[494905380,"San Diego Padres(I. Kennedy)","Texas Rangers(C. Hamels)",4,1441246200000,0,0,1,{"0":[[[-1.0,1.0,"1.0","1.781","2.140",0,1,1743378974,1],[-1.5,1.5,"1.5","1.617","2.490",0,1,221941755,0],[-2.0,2.0,"2.0","1.432","3.020",0,1,1743378972,1]],[["6.5",6.5,"1.952","1.952",221941755,0]],["1.862","2.070",null,221941755,0],0,null,0,0]},null,null,[1,0],1,"I. Kennedy","C. Hamels",null,null,"I",0,0,0,6]],null],[187703,"Nippon Professional Baseball",[[493205012,"Chunichi Dragons(Y. Ono)","Yokohama DeNA BayStars(D. Miura)",1,1441184400000,0,0,1,{"0":[[[1.5,-1.5,"1.5","2.430","1.628",1,0,221942947,0]],[["7.0",7.0,"1.961","1.943",221942947,0]],["2.490","1.606",null,221942947,0],0,null,1,0],"1":[[[0.0,0.0,"0.0","1.609","2.450",0,0,221945206,0]],[["3.5",3.5,"1.934","1.952",221945206,0]],null,1,null,0,0]},null,null,[1,0],1,"Y. Ono","D. Miura",null,null,"I",0,0,0,6],[493205014,"Hanshin Tigers(M. Iwata)","Hiroshima Toyo Carp(K. Maeda)",1,1441184400000,0,0,1,{"0":[[[-1.5,1.5,"1.5","1.729","2.240",0,1,221944778,0]],[["6.5",6.5,"2.060","1.854",221944778,0]],["1.740","2.220",null,221944778,0],0,null,0,0],"1":[[[0.0,0.0,"0.0","2.160","1.769",0,0,221944775,0]],[["3.5",3.5,"2.170","1.763",221944775,0]],null,1,null,0,0]},null,null,[1,0],1,"M. Iwata","K. Maeda",null,null,"I",0,0,0,6],[493205020,"Saitama Seibu Lions(C. Kuo)","Fukuoka SoftBank Hawks(R. van den Hurk)",1,1441184400000,0,0,1,{"0":[[[-1.5,1.5,"1.5","2.020","1.884",0,1,221941128,0]],[["8.0",8.0,"1.862","2.050",221941128,0]],["1.500","2.800",null,221941128,0],0,null,0,0],"1":[[[0.0,0.0,"0.0","2.580","1.558",0,0,221943544,0]],[["4.5",4.5,"1.909","1.980",221943544,0]],null,1,null,0,0]},null,null,[1,0],1,"C. Kuo","R. van den Hurk",null,null,"I",0,0,0,6],[493205018,"Tohoku Rakuten Golden Eagles(Y. Kikuchi)","Orix Buffaloes(D. Tomei)",1,1441184400000,0,0,1,{"0":[[[-1.5,1.5,"1.5","1.657","2.370",0,1,221944838,0]],[["7.0",7.0,"1.943","1.961",221944838,0]],["1.793","2.140",null,221944838,0],0,null,0,0],"1":[[[0.0,0.0,"0.0","2.050","1.847",0,0,221945118,0]],[["3.5",3.5,"1.925","1.961",221945118,0]],null,1,null,0,0]},null,null,[1,0],1,"Y. Kikuchi","D. Tomei",null,null,"I",0,0,0,6],[493205010,"Yomiuri Giants(A. Poreda)","Tokyo Yakult Swallows(Y. Ogawa)",1,1441184400000,0,0,1,{"0":[[[1.5,-1.5,"1.5","2.760","1.510",1,0,221944428,0]],[["6.5",6.5,"1.800","2.130",221944428,0]],["2.130","1.800",null,221944428,0],0,null,1,0],"1":[[[0.0,0.0,"0.0","1.847","2.050",0,0,221945129,0]],[["3.5",3.5,"1.980","1.909",221945129,0]],null,1,null,0,0]},null,null,[1,0],1,"A. Poreda","Y. Ogawa",null,null,"I",0,0,0,6],[493205016,"Hokkaido Nippon Ham Fighters(S. Otani)","Chiba Lotte Marines(A. Ishikawa)",1,1441186200000,0,0,1,{"0":[[[1.5,-1.5,"1.5","1.847","2.070",1,0,221940312,0]],[["7.0",7.0,"2.160","1.781",221940312,0]],["3.590","1.341",null,221940312,0],0,null,1,0],"1":[[[0.0,0.0,"0.0","1.387","3.250",0,0,221940307,0]],[["3.5",3.5,"1.990","1.900",221940307,0]],null,1,null,0,0]},null,null,[1,0],1,"S. Otani","A. Ishikawa",null,null,"I",0,0,0,6]],null],[6227,"Korea Professional Baseball",[[493203394,"Doosan Bears","SK Wyverns",1,1441186200000,0,0,1,{"0":[[[1.5,-1.5,"1.5","2.240","1.689",1,0,221893542,0]],[["10.5",10.5,"2.050","1.813",221893542,0]],["2.310","1.649",null,221893542,0],0,null,1,0],"1":[[[0.0,0.0,"0.0","1.662","2.290",0,0,221893543,0]],[["6.0",6.0,"2.220","1.699",221893543,0]],null,1,null,0,0]},null,null,[1,0],1,null,null,null,null,"I",0,0,0,6],[493203393,"Hanwha Eagles","Kia Tigers",1,1441186200000,0,0,1,{"0":[[[-1.5,1.5,"1.5","1.970","1.877",0,1,221893546,0]],[["9.5",9.5,"1.751","2.140",221893546,0]],["1.500","2.690",null,221893546,0],0,null,0,0],"1":[[[0.0,0.0,"0.0","2.620","1.523",0,0,221893547,0]],[["5.0",5.0,"1.636","2.340",221893547,0]],null,1,null,0,0]},null,null,[1,0],1,null,null,null,null,"I",0,0,0,6],[493203397,"Lotte Giants","KT Wiz",1,1441186200000,0,0,1,{"0":[[[1.5,-1.5,"1.5","1.877","1.970",1,0,221941263,0]],[["11.5",11.5,"1.854","2.000",221941263,0]],["2.930","1.434",null,221941263,0],0,null,1,0],"1":[[[0.0,0.0,"0.0","1.467","2.800",0,0,221941266,0]],[["6.5",6.5,"1.943","1.909",221941266,0]],null,1,null,0,0]},null,null,[1,0],1,null,null,null,null,"I",0,0,0,6],[493203390,"NC Dinos","Samsung Lions",1,1441186200000,0,0,1,{"0":[[[1.5,-1.5,"1.5","2.600","1.529",1,0,221943215,0]],[["9.5",9.5,"2.040","1.826",221943215,0]],["2.140","1.751",null,221943215,0],0,null,1,0],"1":[[[0.0,0.0,"0.0","1.763","2.120",0,0,221943217,0]],[["5.0",5.0,"1.970","1.877",221943217,0]],null,1,null,0,0]},null,null,[1,0],1,null,null,null,null,"I",0,0,0,6],[493203395,"Nexen Heroes","LG Twins",1,1441186200000,0,0,1,{"0":[[[1.5,-1.5,"1.5","1.884","1.970",1,0,221944991,0]],[["10.5",10.5,"1.862","1.990",221944991,0]],["2.680","1.502",null,221944991,0],0,null,1,0],"1":[[[0.0,0.0,"0.0","1.529","2.600",0,0,221893549,0]],[["6.0",6.0,"2.000","1.854",221893549,0]],null,1,null,0,0]},null,null,[1,0],1,null,null,null,null,"I",0,0,0,6]],null]],1441165746162,3,null,[78,27,197]]],"e":null,"lg":0,"pt":0,"ps":null,"d":null}



如果用foreach 一直解析的话,需要用4-5个嵌套,就是foreach里面还有foreach 有4-5个
有没有更好的办法啦



1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2015-9-2 11:51:59 | 显示全部楼层
回复

使用道具 举报

 楼主| 发表于 2015-9-2 11:59:38 | 显示全部楼层
本帖最后由 pyengwoei 于 2015-9-2 12:02 编辑

using System;  
  
namespace SufeiNet  
{  
  
    public class SufeiNet_Test  
    {  
        public object u { get; set; }  
        public object l { get; set; }  
        public IList<IList<object>> n { get; set; }  
        public object e { get; set; }  
        public int lg { get; set; }  
        public int pt { get; set; }  
        public object ps { get; set; }  
        public object d { get; set; }  
    }  
  
}  

这是转化后的类,怎么使用啦,怎么提取数据啦,麻烦了
回复

使用道具 举报

 楼主| 发表于 2015-9-2 12:04:57 | 显示全部楼层
像我这种建立列表的话
List<SiteInfo> jsonlist = (List<SiteInfo>)HttpHelper.JsonToObject<List<SiteInfo>>(sb.ToString());这样可以吗
回复

使用道具 举报

发表于 2015-9-2 14:34:38 | 显示全部楼层
我能说的都在文章里,看一眼就明白了。给了你怎么使用的例子了都 。是不是根本就没看我的文章啊
回复

使用道具 举报

 楼主| 发表于 2015-9-2 15:11:03 | 显示全部楼层
好的,谢谢了
回复

使用道具 举报

发表于 2015-9-2 15:39:19 | 显示全部楼层
上面的例子肯定能解决你的问题,看一下吧,不过方法是在我的框架里写的。我看你不是我的会员,可能用不了,当然也可以从网站下载一下免费的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-11-24 01:36

© 2014-2021

快速回复 返回顶部 返回列表