关于json取值

问题描述

最近在做一个项目,其中有一个模块要求是从直接从优酷上获取视频的真实地址然后在网上找了大量代码,来解析优酷视频的url地址但都有一个关键的地方,就是根据获取到的json,取其中某个键的值,可是到这一步就断章了本来就对json不了解,我把json完整代码贴出来,请各位大侠帮我取个seed和streamfiledids这两个键的值{"data":[{"ct":"s","cs":"2329|2346","logo":"http://g1.ykimg.com/1100641F4655099E80DE960933FDA47FB9AC13-522D-08F6-3596-7B486A02C6BD","seed":7486,"tags":["u5dddu85cfu7ebf","u62fcu8f66","u5305u8f66","u7a3bu57ceu4e9au4e01","u7c73u5806u51b0u5ddd","u81eau9a7e","u5faeu4fe1uff1a360000318"],"categories":"88","videoid":"228681853","vidEncoded":"XOTE0NzI3NDEy","username":"u5dddu85cfu5947u5175u4ff1u4e50u90e8","userid":"154402212","title":"u897fu884cu6f2bu8bb0u5dddu85cfu7ebf","up":2,"down":0,"ts":"oIhb5jkK4R4zK9k7AdBjupI","tsup":"oIhfgzoK4R4zK9k7ArVnupI","preview":{"thumbs":["0521000255099EDF6C1E25475406A2C6","0521010255099EDF6C1E25475406A2C6"],"sectiontime":"6000","host":"http://g3.ykimg.com/"},"key1":"bd70c8ca","key2":"3917d3a75f1c412a","tt":"0","ip":1987729206,"ep":"NAXSRwQWI77d2PbH9uJxVoLyuhY51wrDXBY=","videoSource":"1","seconds":"791.61","streamfileids":{"3gphd":"59*38*59*59*11*59*59*35*59*59*37*37*59*20*23*35*31*65*27*65*35*41*59*20*38*38*8*17*39*21*27*59*41*41*38*27*17*18*60*39*35*27*27*60*37*11*65*8*60*27*27*35*35*60*20*20*17*18*31*23*21*18*35*37*38*39*","flv":"59*38*59*59*59*11*59*11*59*59*37*37*59*20*23*35*37*31*27*65*35*41*59*20*38*38*8*17*39*21*27*59*41*41*38*27*17*18*60*39*35*27*27*60*37*11*65*8*60*27*27*35*35*60*20*20*17*18*31*23*21*18*35*37*38*39*","mp4":"59*38*59*59*59*27*59*11*59*59*37*37*59*20*27*27*35*39*27*65*35*41*59*20*38*38*8*17*39*21*27*59*41*41*38*27*17*18*60*39*35*27*27*60*37*11*65*8*60*27*27*35*35*60*20*20*17*18*31*23*21*18*35*37*38*39*","hd2":"59*38*59*59*59*35*59*37*59*59*37*37*59*20*27*18*41*39*27*65*35*41*59*20*38*38*8*17*39*21*27*59*41*41*38*27*17*18*60*39*35*27*27*60*37*11*65*8*60*27*27*35*35*60*20*20*17*18*31*23*21*18*35*37*38*39*","hd3":"59*38*59*59*27*59*59*65*59*59*37*37*59*20*20*41*23*17*27*65*35*41*59*20*38*38*8*17*39*21*27*59*41*41*38*27*17*18*60*39*35*27*27*60*37*11*65*8*60*27*27*35*35*60*20*20*17*18*31*23*21*18*35*37*38*39*"},"segs":{"3gphd":[{"no":"0","size":"29763629","seconds":792,"k":"68b1eb78c1c038ea24122ee6","k2":"16711c1fb5d2715da"}],"flv":[{"no":"0","size":"14993808","seconds":418,"k":"b94fe81dcd916d9b282a6d6f","k2":"10f152238444df915"},{"no":"1","size":"13320549","seconds":374,"k":"45ff17b9c400345a282a6d6f","k2":"1ba7f35efed585fc1"}],"mp4":[{"no":"0","size":"24867377","seconds":384,"k":"6f40e7fef4512719282a6d6f","k2":"1688e961ad5f9a387"},{"no":"1","size":"29465751","seconds":408,"k":"21ec715f4c03cef1261e4e2b","k2":"173a08249b1fe12c0"}],"hd2":[{"no":"0","size":"21376484","seconds":190,"k":"8188cce7ea06302b261e4e2b","k2":"1519a030d29c750bf"},{"no":"1","size":"32811618","seconds":194,"k":"973b48febd8f1142282a6d6f","k2":"1839f6382b99a02fd"},{"no":"2","size":"36896826","seconds":185,"k":"22a6646fcd6a0641261e4e2b","k2":"1c52660ab390f439c"},{"no":"3","size":"12637867","seconds":104,"k":"667b625915b9a229261e4e2b","k2":"18a3da498cbb68a3f"},{"no":"4","size":"14921113","seconds":119,"k":"16cd5ec8027cc6e624122ee6","k2":"15d62e43db6742888"}],"hd3":[{"no":"0","size":"30886746","seconds":138,"k":"3570c8371868fd2a261e4e2b","k2":"1a97c6ed09ad3e1bd"},{"no":"1","size":"31956022","seconds":145,"k":"ec0b23c38c24aae524122ee6","k2":"1e211d127ebe5a2e7"},{"no":"2","size":"58352773","seconds":126,"k":"a31e2739acdc52ee282a6d6f","k2":"10a0af7a914a9f6b0"},{"no":"3","size":"46330722","seconds":140,"k":"9523ff55ed7426b424122ee6","k2":"1338c111d790aac89"},{"no":"4","size":"35148463","seconds":128,"k":"290a4746dca32b9a24122ee6","k2":"17f1dc8fefbe9c323"},{"no":"5","size":"28229840","seconds":115,"k":"2d4e87893205965e261e4e2b","k2":"1c9bc7255dd49e530"}]},"streamsizes":{"3gphd":"29763629","flv":"28314357","mp4":"54333128","hd2":"118643908","hd3":"230904566"},"stream_ids":{"3gphd":"289704293","flv":"289703897","mp4":"289733794","hd2":"289740022","hd3":"289762856"},"streamlogos":{"3gphd":1,"flv":1,"mp4":1,"hd2":1,"hd3":1},"streamtypes":["3gphd","flv","mp4","hd2","hd3"],"streamtypes_o":["hd2","flvhd","mp4","3gphd","hd3"]}],"user":{"id":0,"acc_support":true},"controller":{"search_count":true,"mp4_restrict":1,"stream_mode":2,"video_capture":true,"hd3_enabled":false,"area_code":510100,"dma_code":4134,"continuous":0,"playmode":"normal","circle":false,"tsflag":false,"other_disable":false,"xplayer_disable":false,"app_disable":false,"share_disabled":false,"download_disabled":false,"pc_disabled":false,"pad_disabled":false,"mobile_disabled":false,"tv_disabled":false,"comment_disabled":false}}{"data":[{"ct":"s","cs":"2329|2346","logo":"http://g1.ykimg.com/1100641F4655099E80DE960933FDA47FB9AC13-522D-08F6-3596-7B486A02C6BD","seed":5851,"tags":["u5dddu85cfu7ebf","u62fcu8f66","u5305u8f66","u7a3bu57ceu4e9au4e01","u7c73u5806u51b0u5ddd","u81eau9a7e","u5faeu4fe1uff1a360000318"],"categories":"88","videoid":"228681853","vidEncoded":"XOTE0NzI3NDEy","username":"u5dddu85cfu5947u5175u4ff1u4e50u90e8","userid":"154402212","title":"u897fu884cu6f2bu8bb0u5dddu85cfu7ebf","up":2,"down":0,"ts":"vsq*kzkKgPozz7g7AaWG*Iw","tsup":"vsqyujoKgPozz7g7AoyK*Iw","preview":{"thumbs":["0521000255099EDF6C1E25475406A2C6","0521010255099EDF6C1E25475406A2C6"],"sectiontime":"6000","host":"http://g2.ykimg.com/"},"key1":"b344ebba","key2":"d8aa24e7e6be1820","tt":"0","ip":1987729206,"ep":"PwXSRwQZIbnT1PbD/OJxVof8sBZu1w7JXBo=","videoSource":"1","seconds":"791.61","streamfileids":{"3gphd":"53*27*53*53*28*53*53*65*53*53*17*17*53*25*1*65*37*54*47*54*65*16*53*25*27*27*14*44*30*50*47*53*16*16*27*47*44*48*46*30*65*47*47*46*17*28*54*14*46*47*47*65*65*46*25*25*44*48*37*1*50*48*65*17*27*30*","flv":"53*27*53*53*53*28*53*28*53*53*17*17*53*25*1*65*17*37*47*54*65*16*53*25*27*27*14*44*30*50*47*53*16*16*27*47*44*48*46*30*65*47*47*46*17*28*54*14*46*47*47*65*65*46*25*25*44*48*37*1*50*48*65*17*27*30*","mp4":"53*27*53*53*53*47*53*28*53*53*17*17*53*25*47*47*65*30*47*54*65*16*53*25*27*27*14*44*30*50*47*53*16*16*27*47*44*48*46*30*65*47*47*46*17*28*54*14*46*47*47*65*65*46*25*25*44*48*37*1*50*48*65*17*27*30*","hd2":"53*27*53*53*53*65*53*17*53*53*17*17*53*25*47*48*16*30*47*54*65*16*53*25*27*27*14*44*30*50*47*53*16*16*27*47*44*48*46*30*65*47*47*46*17*28*54*14*46*47*47*65*65*46*25*25*44*48*37*1*50*48*65*17*27*30*","hd3":"53*27*53*53*47*53*53*54*53*53*17*17*53*25*25*16*1*44*47*54*65*16*53*25*27*27*14*44*30*50*47*53*16*16*27*47*44*48*46*30*65*47*47*46*17*28*54*14*46*47*47*65*65*46*25*25*44*48*37*1*50*48*65*17*27*30*"},"segs":{"3gphd":[{"no":"0","size":"29763629","seconds":792,"k":"a42c6fe0964bd07724122edf","k2":"16711c1fb5d2715da"}],"flv":[{"no":"0","size":"14993808","seconds":418,"k":"23f5e0bcc4651dbb24122edf","k2":"10f152238444df915"},{"no":"1","size":"13320549","seconds":374,"k":"e1f779d0183fada224122edf","k2":"1ba7f35efed585fc1"}],"mp4":[{"no":"0","size":"24867377","seconds":384,"k":"ea262b322594960c24122edf","k2":"1688e961ad5f9a387"},{"no":"1","size":"29465751","seconds":408,"k":"3d222bd980039f87282a6d5f","k2":"173a08249b1fe12c0"}],"hd2":[{"no":"0","size":"21376484","seconds":190,"k":"c67c3c076b3fb61124122edf","k2":"1519a030d29c750bf"},{"no":"1","size":"32811618","seconds":194,"k":"f1abaf1bd27427b124122edf","k2":"1839f6382b99a02fd"},{"no":"2","size":"36896826","seconds":185,"k":"1d5b8665f9d86802261e4e1f","k2":"1c52660ab390f439c"},{"no":"3","size":"12637867","seconds":104,"k":"ac11e518d521f1fa261e4e1f","k2":"18a3da498cbb68a3f"},{"no":"4","size":"14921113","seconds":119,"k":"5a02208b7d49a56c282a6d5f","k2":"15d62e43db6742888"}],"hd3":[{"no":"0","size":"30886746","seconds":138,"k":"b571fd69eb5605dc261e4e1f","k2":"1a97c6ed09ad3e1bd"},{"no":"1","size":"31956022","seconds":145,"k":"77a87c71bffe12ef24122edf","k2":"1e211d127ebe5a2e7"},{"no":"2","size":"58352773","seconds":126,"k":"91b49a5996b00cea282a6d5f","k2":"10a0af7a914a9f6b0"},{"no":"3","size":"46330722","seconds":140,"k":"89dd16e2cedd3a1a261e4e1f","k2":"1338c111d790aac89"},{"no":"4","size":"35148463","seconds":128,"k":"b1ee115e6dce3172261e4e1f","k2":"17f1dc8fefbe9c323"},{"no":"5","size":"28229840","seconds":115,"k":"b2ff893eb06c2c1b282a6d5f","k2":"1c9bc7255dd49e530"}]},"streamsizes":{"3gphd":"29763629","flv":"28314357","mp4":"54333128","hd2":"118643908","hd3":"230904566"},"stream_ids":{"3gphd":"289704293","flv":"289703897","mp4":"289733794","hd2":"289740022","hd3":"289762856"},"streamlogos":{"3gphd":1,"flv":1,"mp4":1,"hd2":1,"hd3":1},"streamtypes":["3gphd","flv","mp4","hd2","hd3"],"streamtypes_o":["hd2","flvhd","mp4","3gphd","hd3"]}],"user":{"id":0,"acc_support":true},"controller":{"search_count":true,"mp4_restrict":1,"stream_mode":1,"video_capture":true,"hd3_enabled":false,"area_code":510100,"dma_code":4134,"continuous":0,"playmode":"normal","circle":false,"tsflag":false,"other_disable":false,"xplayer_disable":false,"app_disable":false,"share_disabled":false,"download_disabled":false,"pc_disabled":false,"pad_disabled":false,"mobile_disabled":false,"tv_disabled":false,"comment_disabled":false}}

解决方案

解决方案二:
自己先顶下,解析的时候要不要把data去掉呢
解决方案三:
定义一个对象,只包含你想要的字段,然后序列化就行了
解决方案四:
你是用什么来解析?jquery还是C#程序?如果是jquery那就是vardataInfo=JSON.parse(对象);然后用dataInfo.data.seed试试,如果是用C#那就用Network.JOSN.dll试试
解决方案五:
用.net,但在序列化时,报错,说有一些无效字符,也是找了好多方法,有思路,就是在写代码的时候,太纠结了
解决方案六:
可以用Newtonsoft.Json.dll这个来试试解析
解决方案七:
引用4楼wangjianchao的回复:

用.net,但在序列化时,报错,说有一些无效字符,也是找了好多方法,有思路,就是在写代码的时候,太纠结了

.netframework其实并没有提供完整的所谓json解析功能,它只是在.net内存对象与输出的string之间进行“json序列化、反序列化”。使用Newtonsoft可以得到JObject、JArray、JToken等等数据结构,使用它才可以灵活地处理json数据。
解决方案八:
可以用json.net或者windows.data.json接卸json字符串,看下这个链接http://james.newtonking.com/archive/2012/09/14/json-net-vs-windows-data-json
解决方案九:
先存在stringbuild中,然后来解析
解决方案十:
眼睛花了,太多了
解决方案十一:
来,爷是人肉读码机!首先下载引用Newtonsoft.Json.dlldynamicjsonObj=JsonConvert.DeserializeObject("你那一串json字符串");varseed=jsonObj.data[0].seed;var3gphd=jsonObj.data[0].streamfileids.3gphd;varflv=jsonObj.data[0].streamfileids.flv;varmp4=jsonObj.data[0].streamfileids.mp4;顺带一提,lz的JSON粘贴了两遍啦,解析方然报错,删掉其中一个之后解析成功。太长不好读什么的,试试在线json解析http://www.bejson.com/jsonviewernew/
解决方案十二:
引用10楼zhenshana的回复:

来,爷是人肉读码机!首先下载引用Newtonsoft.Json.dlldynamicjsonObj=JsonConvert.DeserializeObject("你那一串json字符串");varseed=jsonObj.data[0].seed;var3gphd=jsonObj.data[0].streamfileids.3gphd;varflv=jsonObj.data[0].streamfileids.flv;varmp4=jsonObj.data[0].streamfileids.mp4;顺带一提,lz的JSON粘贴了两遍啦,解析方然报错,删掉其中一个之后解析成功。太长不好读什么的,试试在线json解析http://www.bejson.com/jsonviewernew/

不明觉厉

时间: 2024-11-10 08:13:31

关于json取值的相关文章

ajax返回json取值问题

问题描述 ajax返回json取值问题 解决方案 要用 data["agentDTO.agentCode"]来获取,因为你键名称包含了点操作符 要是data.agetnDTO.agentCode这样是获取data节点下的agentDTO节点下的agentCode了,当然undefined 解决方案二: 同意楼上,如果用.的取值方式,楼主的变量agetnDTO.agentCode会被拆分成两个变量,自然就与事实不一致了. 解决方案三: agetnDTO.agentCode在你的代码里应该

asp.net-C#后台解析异形json取值

问题描述 C#后台解析异形json取值 大家看看这种json该如何在后台解析取值({""results"":[{""CityCode"":""0591""station"":""12""district"":""三环以内""freight"":&qu

jsonarray-解析过后的json取值问题

问题描述 解析过后的json取值问题 解析过后的json,在循环取值的时候报错,用JSONArray jsonArrayIn = jsonArray.getJSONArray(i)时候报JSONArray[33] is not a JSONArray, ,我试着用JSONObject jons = jsonArray.getJSONObject(i);又说却 JSONArray[33] is not a JSONObject,,此刻我凌乱了,求指导 解决方案 if(jsonArray!=null

php json取值问题,请大家帮忙

问题描述 php json取值问题,请大家帮忙 {""success"":""1""result"":{""count"":""1""lists"":[{""areaid"":""93""postcode"":

JSON取值前判断_json

复制代码 代码如下: public static void main(String[] args)throws Exception{      String jsonStr1="{\"access_token\":\"OezXcEiiBSKSxW0eoylIeIVb08lFhyeFsq6cUJJNo8XYLoJjqYARJOZUrnqhfvnyMKOSjz5SHPHGUmt6f09_762MWQ0HLnZtffDPyD2A6TgCqWlZAEsHLhIaaQVYx1

jquery实现下拉菜单的二级联动利用json对象从DB取值显示联动

 这篇文章主要介绍了jquery实现下拉菜单的二级联动利用json对象从DB取值显示联动,需要的朋友可以参考下 利用struts2和Ajax实现json对象的传输,然后实现菜单的二级联动    下面是我的 js文件原码:   代码如下: var mail={  //初始化  init:{  //初始化数据  initdata:{  did:'',  ttitle:'',  sendpassword:'',  description:''  },  //初始化事件  initevent:{  Da

实用ExtJS教程100例-011:ExtJS Form 使用JSON数据赋值和取值

上一节中我们演示了ExtJS Form的异步加载和提交数据,本节中我们将演示如何使用JSON数据为ExtJS Form中的字段赋值和取值. 系列ExtJS教程持续更新中,点击查看>>最新ExtJS教程目录 使用JSON数据为字段赋值 var formCmp = this.up("form"); var form = formCmp.getForm(); var userValues = { UserName: "Qi Fei", Email: "

当json键为数字时的取值方法解析_javascript技巧

当json的键为数字时如何取值,如: var aa={'111':'aaaaa'}; alert(sss.111); 这样是不行的,alert不会弹任何东西. json的键必须是一个对象,才能取出东西,如: var aa={'s111s':'aaaaa'}; var idd="s111s"; alert(sss.idd); 解答: 对于数字键名或者非正常变量字符(比如有空格),必须使用 aa[x]的方式.var aa={'111':'aaaaa'}; alert(sss["1

json序列化对象后,json里面的list数据怎么取值赋给下面的“entryNode_Text”

问题描述 json序列化对象后,json里面的list数据怎么取值赋给下面的"entryNode_Text" XmlNode entryNode = xmldoc.CreateElement("entry"); XmlText entryNode_Text = xmldoc.CreateTextNode("231234"); entryNode.AppendChild(entryNode_Text); XmlNode title1 = xmldo