首页 新闻 会员 周边 捐助

怎么把多层SJON数据转换成多维数组 我自己转换看取不出来啊

0
悬赏园豆:5 [已解决问题] 解决于 2016-03-24 15:55

 {"header":{"status":"1","markid":""},"body":{"videofile":{"infos":{"mp4_180":{"backUrl2":"http:\/\/play.g3proxy.lecloud.com\/vod\/v2\/MTYyLzMyLzU1L2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMDE2MDYxNjkxLWF2Yy0xMjgzMzgtYWFjLTMyMDAwLTI3NjkwNjctNTc4NDc4OTItY2RkYWExZWFjYzE4MWYyZjQwYTYyMzQ0OTRmZWM0MDYtMTQ1MTg4MzU1MjQ2Ny5tcDQ=?b=167&mmsid=41080393&tm=1453967403&key=44316f829b240caa11fca65c6e479481&platid=3&splatid=347&playid=0&tss=no&vtype=58&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&retry=1&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","filesize":"57847892","backUrl1":"http:\/\/117.121.54.219\/vod\/v2\/MTYyLzMyLzU1L2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMDE2MDYxNjkxLWF2Yy0xMjgzMzgtYWFjLTMyMDAwLTI3NjkwNjctNTc4NDc4OTItY2RkYWExZWFjYzE4MWYyZjQwYTYyMzQ0OTRmZWM0MDYtMTQ1MTg4MzU1MjQ2Ny5tcDQ=?b=167&mmsid=41080393&tm=1453967403&key=44316f829b240caa11fca65c6e479481&platid=3&splatid=347&playid=0&tss=no&vtype=58&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","mainUrl":"http:\/\/play.g3proxy.lecloud.com\/vod\/v2\/MTYyLzMyLzU1L2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMDE2MDYxNjkxLWF2Yy0xMjgzMzgtYWFjLTMyMDAwLTI3NjkwNjctNTc4NDc4OTItY2RkYWExZWFjYzE4MWYyZjQwYTYyMzQ0OTRmZWM0MDYtMTQ1MTg4MzU1MjQ2Ny5tcDQ=?b=167&mmsid=41080393&tm=1453967403&key=44316f829b240caa11fca65c6e479481&platid=3&splatid=347&playid=0&tss=no&vtype=58&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","backUrl0":"http:\/\/bplay.g3proxy.lecloud.com\/vod\/v2\/MTYyLzMyLzU1L2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMDE2MDYxNjkxLWF2Yy0xMjgzMzgtYWFjLTMyMDAwLTI3NjkwNjctNTc4NDc4OTItY2RkYWExZWFjYzE4MWYyZjQwYTYyMzQ0OTRmZWM0MDYtMTQ1MTg4MzU1MjQ2Ny5tcDQ=?b=167&mmsid=41080393&tm=1453967403&key=44316f829b240caa11fca65c6e479481&platid=3&splatid=347&playid=0&tss=no&vtype=58&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","storePath":"162\/32\/55\/letv-uts\/14\/ver_00_22-1016061691-avc-128338-aac-32000-2769067-57847892-cddaa1eacc181f2f40a6234494fec406-1451883552467.mp4"},"mp4_1300":{"backUrl2":"http:\/\/play.g3proxy.lecloud.com\/vod\/v2\/MTc5LzI0LzQ3L2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMDE2MDYxNjkwLWF2Yy03OTIxODMtYWFjLTY0MDAwLTI3Njg0ODAtMjk5MzU4MzM0LTI2Y2ZhYTZjZmFlNTExN2EwZThkYTUxZmQzODQwZTEwLTE0NTE4ODI3NDEyNDMubXA0?b=864&mmsid=41080393&tm=1453967403&key=2cbe8f37a54208e065668cbd35ab710a&platid=3&splatid=347&playid=0&tss=no&vtype=22&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&retry=1&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","filesize":"299358334","backUrl1":"http:\/\/117.121.54.219\/vod\/v2\/MTc5LzI0LzQ3L2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMDE2MDYxNjkwLWF2Yy03OTIxODMtYWFjLTY0MDAwLTI3Njg0ODAtMjk5MzU4MzM0LTI2Y2ZhYTZjZmFlNTExN2EwZThkYTUxZmQzODQwZTEwLTE0NTE4ODI3NDEyNDMubXA0?b=864&mmsid=41080393&tm=1453967403&key=2cbe8f37a54208e065668cbd35ab710a&platid=3&splatid=347&playid=0&tss=no&vtype=22&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","mainUrl":"http:\/\/play.g3proxy.lecloud.com\/vod\/v2\/MTc5LzI0LzQ3L2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMDE2MDYxNjkwLWF2Yy03OTIxODMtYWFjLTY0MDAwLTI3Njg0ODAtMjk5MzU4MzM0LTI2Y2ZhYTZjZmFlNTExN2EwZThkYTUxZmQzODQwZTEwLTE0NTE4ODI3NDEyNDMubXA0?b=864&mmsid=41080393&tm=1453967403&key=2cbe8f37a54208e065668cbd35ab710a&platid=3&splatid=347&playid=0&tss=no&vtype=22&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","backUrl0":"http:\/\/bplay.g3proxy.lecloud.com\/vod\/v2\/MTc5LzI0LzQ3L2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMDE2MDYxNjkwLWF2Yy03OTIxODMtYWFjLTY0MDAwLTI3Njg0ODAtMjk5MzU4MzM0LTI2Y2ZhYTZjZmFlNTExN2EwZThkYTUxZmQzODQwZTEwLTE0NTE4ODI3NDEyNDMubXA0?b=864&mmsid=41080393&tm=1453967403&key=2cbe8f37a54208e065668cbd35ab710a&platid=3&splatid=347&playid=0&tss=no&vtype=22&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","storePath":"179\/24\/47\/letv-uts\/14\/ver_00_22-1016061690-avc-792183-aac-64000-2768480-299358334-26cfaa6cfae5117a0e8da51fd3840e10-1451882741243.mp4"},"mp4_350":{"backUrl2":"http:\/\/play.g3proxy.lecloud.com\/vod\/v2\/MTcyLzQvMjgvbGV0di11dHMvMTQvdmVyXzAwXzIyLTEwMTYwNjE2OTItYXZjLTEyODI2MS1hYWMtMzIwMDAtMjc2OTA2Ny01ODQ4NTQ4MS05OTQ1YjVkY2ZlZTVhMGE1Nzg0YmZiZDA3NTg0YzQ4MC0xNDUxODgzNTc1OTI5Lm1wNA==?b=168&mmsid=41080393&tm=1453967403&key=d5448d9d51bcaa63e63318849eaa7a9c&platid=3&splatid=347&playid=0&tss=no&vtype=9&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&retry=1&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","filesize":"58485481","backUrl1":"http:\/\/117.121.54.219\/vod\/v2\/MTcyLzQvMjgvbGV0di11dHMvMTQvdmVyXzAwXzIyLTEwMTYwNjE2OTItYXZjLTEyODI2MS1hYWMtMzIwMDAtMjc2OTA2Ny01ODQ4NTQ4MS05OTQ1YjVkY2ZlZTVhMGE1Nzg0YmZiZDA3NTg0YzQ4MC0xNDUxODgzNTc1OTI5Lm1wNA==?b=168&mmsid=41080393&tm=1453967403&key=d5448d9d51bcaa63e63318849eaa7a9c&platid=3&splatid=347&playid=0&tss=no&vtype=9&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","mainUrl":"http:\/\/play.g3proxy.lecloud.com\/vod\/v2\/MTcyLzQvMjgvbGV0di11dHMvMTQvdmVyXzAwXzIyLTEwMTYwNjE2OTItYXZjLTEyODI2MS1hYWMtMzIwMDAtMjc2OTA2Ny01ODQ4NTQ4MS05OTQ1YjVkY2ZlZTVhMGE1Nzg0YmZiZDA3NTg0YzQ4MC0xNDUxODgzNTc1OTI5Lm1wNA==?b=168&mmsid=41080393&tm=1453967403&key=d5448d9d51bcaa63e63318849eaa7a9c&platid=3&splatid=347&playid=0&tss=no&vtype=9&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","backUrl0":"http:\/\/bplay.g3proxy.lecloud.com\/vod\/v2\/MTcyLzQvMjgvbGV0di11dHMvMTQvdmVyXzAwXzIyLTEwMTYwNjE2OTItYXZjLTEyODI2MS1hYWMtMzIwMDAtMjc2OTA2Ny01ODQ4NTQ4MS05OTQ1YjVkY2ZlZTVhMGE1Nzg0YmZiZDA3NTg0YzQ4MC0xNDUxODgzNTc1OTI5Lm1wNA==?b=168&mmsid=41080393&tm=1453967403&key=d5448d9d51bcaa63e63318849eaa7a9c&platid=3&splatid=347&playid=0&tss=no&vtype=9&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","storePath":"172\/4\/28\/letv-uts\/14\/ver_00_22-1016061692-avc-128261-aac-32000-2769067-58485481-9945b5dcfee5a0a5784bfbd07584c480-1451883575929.mp4"},"mp4_1000":{"backUrl2":"http:\/\/play.g3proxy.lecloud.com\/vod\/v2\/MTYwLzQyLzI3L2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMDE2MDYxNjkzLWF2Yy00MTY4ODQtYWFjLTMyMDAwLTI3Njg0ODAtMTU4NDAxODM3LWNkYjZhMzFkYTZjYzhmYjk3M2JiYmM3ZmM4NjJkMTQ2LTE0NTE4ODI0ODMyNzcubXA0?b=457&mmsid=41080393&tm=1453967403&key=c16acc97621c961e32a8f5c6d7b40ea6&platid=3&splatid=347&playid=0&tss=no&vtype=13&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&retry=1&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","filesize":"158401837","backUrl1":"http:\/\/117.121.54.219\/vod\/v2\/MTYwLzQyLzI3L2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMDE2MDYxNjkzLWF2Yy00MTY4ODQtYWFjLTMyMDAwLTI3Njg0ODAtMTU4NDAxODM3LWNkYjZhMzFkYTZjYzhmYjk3M2JiYmM3ZmM4NjJkMTQ2LTE0NTE4ODI0ODMyNzcubXA0?b=457&mmsid=41080393&tm=1453967403&key=c16acc97621c961e32a8f5c6d7b40ea6&platid=3&splatid=347&playid=0&tss=no&vtype=13&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","mainUrl":"http:\/\/play.g3proxy.lecloud.com\/vod\/v2\/MTYwLzQyLzI3L2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMDE2MDYxNjkzLWF2Yy00MTY4ODQtYWFjLTMyMDAwLTI3Njg0ODAtMTU4NDAxODM3LWNkYjZhMzFkYTZjYzhmYjk3M2JiYmM3ZmM4NjJkMTQ2LTE0NTE4ODI0ODMyNzcubXA0?b=457&mmsid=41080393&tm=1453967403&key=c16acc97621c961e32a8f5c6d7b40ea6&platid=3&splatid=347&playid=0&tss=no&vtype=13&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","backUrl0":"http:\/\/bplay.g3proxy.lecloud.com\/vod\/v2\/MTYwLzQyLzI3L2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMDE2MDYxNjkzLWF2Yy00MTY4ODQtYWFjLTMyMDAwLTI3Njg0ODAtMTU4NDAxODM3LWNkYjZhMzFkYTZjYzhmYjk3M2JiYmM3ZmM4NjJkMTQ2LTE0NTE4ODI0ODMyNzcubXA0?b=457&mmsid=41080393&tm=1453967403&key=c16acc97621c961e32a8f5c6d7b40ea6&platid=3&splatid=347&playid=0&tss=no&vtype=13&cvid=768876645571&payff=0&pip=fc086fb11a6f4a36ce405a1bdbbf16d4&format=1&sign=mb&dname=mobile&expect=3&p1=0&p2=00&p3=003&tag=mobile&pid=","storePath":"160\/42\/27\/letv-uts\/14\/ver_00_22-1016061693-avc-416884-aac-32000-2768480-158401837-cdb6a31da6cc8fb973bbbc7fc862d146-1451882483277.mp4"}},"mmsid":"41080393"}}}

 
 
恋世情缘的主页 恋世情缘 | 初学一级 | 园豆:117
提问于:2016-01-28 16:10
< >
分享
最佳答案
0
 1 public class Rootobject
 2 {
 3     public Header header { get; set; }
 4     public Body body { get; set; }
 5 }
 6 
 7 public class Header
 8 {
 9     public string status { get; set; }
10     public string markid { get; set; }
11 }
12 
13 public class Body
14 {
15     public Videofile videofile { get; set; }
16 }
17 
18 public class Videofile
19 {
20     public Infos infos { get; set; }
21     public string mmsid { get; set; }
22 }
23 
24 public class Infos
25 {
26     public Mp4_180 mp4_180 { get; set; }
27     public Mp4_1300 mp4_1300 { get; set; }
28     public Mp4_350 mp4_350 { get; set; }
29     public Mp4_1000 mp4_1000 { get; set; }
30 }
31 
32 public class Mp4_180
33 {
34     public string backUrl2 { get; set; }
35     public string filesize { get; set; }
36     public string backUrl1 { get; set; }
37     public string mainUrl { get; set; }
38     public string backUrl0 { get; set; }
39     public string storePath { get; set; }
40 }
41 
42 public class Mp4_1300
43 {
44     public string backUrl2 { get; set; }
45     public string filesize { get; set; }
46     public string backUrl1 { get; set; }
47     public string mainUrl { get; set; }
48     public string backUrl0 { get; set; }
49     public string storePath { get; set; }
50 }
51 
52 public class Mp4_350
53 {
54     public string backUrl2 { get; set; }
55     public string filesize { get; set; }
56     public string backUrl1 { get; set; }
57     public string mainUrl { get; set; }
58     public string backUrl0 { get; set; }
59     public string storePath { get; set; }
60 }
61 
62 public class Mp4_1000
63 {
64     public string backUrl2 { get; set; }
65     public string filesize { get; set; }
66     public string backUrl1 { get; set; }
67     public string mainUrl { get; set; }
68     public string backUrl0 { get; set; }
69     public string storePath { get; set; }
70 }
View Code

这个是VS自动生成的实体类.

可以看出这个格式有问题.

收获园豆:1
吴瑞祥 | 高人七级 |园豆:29449 | 2016-01-28 16:24

你那个看不懂啊。。VS不懂、  这个格式没问题。 我用格式化工具测试没问题、

恋世情缘 | 园豆:117 (初学一级) | 2016-01-28 16:26

@恋世情缘: 是符合json格式了.但里面的是对象.不是数组.你不能反序列化成数组.

吴瑞祥 | 园豆:29449 (高人七级) | 2016-01-28 16:30

@吴瑞祥: 只能转换成数组 ,JSON数据不是也能强制转换成数组吗?

恋世情缘 | 园豆:117 (初学一级) | 2016-01-28 16:31

@恋世情缘: 所以说你的json格式有问题.infos字段.字面理解你应该想要的是一个数组.但实际上他是一个对象.不能被解析成数组.你的问题应该也是出在这里

直接解析是不可能的,你只能解析成键值对.然后代码处理成.看他的对象明明方式,应该是把ID放在自对象的KEY后面了.还得把这个ID转到实体里

吴瑞祥 | 园豆:29449 (高人七级) | 2016-01-28 16:59

@吴瑞祥: 我明天看看能不能用对象,能吧我写个简单例子嘛,谢谢

恋世情缘 | 园豆:117 (初学一级) | 2016-01-29 00:54
其他回答(4)
0

呃,你可以foreach遍历  info  添加每个MP4信息到List<MP4>然后 再ToArray()一下

收获园豆:2
龙葛格 | 园豆:782 (小虾三级) | 2016-01-28 16:21

能不能给我写个例子。。我试了半天也不行。取不出来

支持(0) 反对(0) 恋世情缘 | 园豆:117 (初学一级) | 2016-01-28 16:25

@恋世情缘: 刚才上班,时间比较仓促。抱歉我没有看清楚你的问题,首先来说,因为你这个数据模型中自上而下都是一对多的关系,肯定不能每个属性作为一个数据元素。比如某条数据可能有4个mp4,而另一条有5个,这就造成了数据长度不固定,而数组在内存中是一块连续的,长度固定的区域;再定义的时候就必须给出数据长度。所以你这个数据不要用数组存储,而链表长度不固定,存储空间不一定连续,所以你应该使用多维链表,而不是多维数组。

额,,不知道这样的回答你是不是满意。

支持(0) 反对(0) 龙葛格 | 园豆:782 (小虾三级) | 2016-01-28 19:58

@龙葛格: 多维表没听过啊。能不能帮我写个可用的例子。朋友

支持(0) 反对(0) 恋世情缘 | 园豆:117 (初学一级) | 2016-01-29 00:53

@恋世情缘: 多维数组是数组套数组,多维表就是链表套链表啊

支持(0) 反对(0) 龙葛格 | 园豆:782 (小虾三级) | 2016-01-29 09:20

@龙葛格: 压根也没接触过链表。。。

支持(0) 反对(0) 恋世情缘 | 园豆:117 (初学一级) | 2016-01-29 09:25

@恋世情缘: 找本讲数据结构的书来看看吧,长时间不用确实会忘。哈哈

支持(0) 反对(0) 龙葛格 | 园豆:782 (小虾三级) | 2016-01-29 09:32

@龙葛格: 晕、、

支持(0) 反对(0) 恋世情缘 | 园豆:117 (初学一级) | 2016-01-29 09:37
0

如1楼所说,如果你不会使用多维链表,可以使用交错数组试下。

飞翔の金雕 | 园豆:364 (菜鸟二级) | 2016-01-29 08:54

咋 感觉你们说的都没听过。。好高端的赶脚

支持(0) 反对(0) 恋世情缘 | 园豆:117 (初学一级) | 2016-01-29 09:24
0

json_decode('你的json字符串',true);

收获园豆:1
I'mWaitingForYou | 园豆:200 (初学一级) | 2016-01-29 15:57
0

你现在是JSON代码,你可以alert(JSON.stringify(data));  data就是你返回的那个数据,转成字符串后你就很容易看清楚的,你先试试

收获园豆:1
-JackoChan | 园豆:162 (初学一级) | 2016-03-03 23:29

你这是JSON方法吗?不懂

支持(0) 反对(0) 恋世情缘 | 园豆:117 (初学一级) | 2016-03-03 23:35

@恋世情缘: 你后台是用什么写的,你可以直接在后台处理好,然后再转成json传送前台就好了

支持(0) 反对(0) -JackoChan | 园豆:162 (初学一级) | 2016-03-03 23:37

@ChEn嘉豪: 这是别人页面返回的东西。我采集来自己用的

支持(0) 反对(0) 恋世情缘 | 园豆:117 (初学一级) | 2016-03-03 23:38
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册