//单个情况
str1 = "{id:"+ id+",name:"+ name+"}"; eval("(" + str1+ ")");
//多个情况
str2 = "{[{...},{...}]}" eval(str2);
location.search取每一个参数的值 转换json格式
//?pname=14 - 解脫&author='aaa'©right='bbb'&info='cccc''
var urlvalue ;
var url = location.search;
url = url.substring( 1 ,url.length);
var arrurl = url.split( ' & ' );
arrurlvalue = " { " ;
for ( var i = 0 ;i < arrurl.length;i ++ ){
if (i == arrurl.length - 1 )
arrurlvalue += arrurl[i].split( ' = ' )[ 0 ] + " : " + " ' " + arrurl[i].split( ' = ' )[ 1 ] + " ' " ;
else
arrurlvalue += arrurl[i].split( ' = ' )[ 0 ] + " : " + " ' " + arrurl[i].split( ' = ' )[ 1 ] + " ' " + " , " ;
}
//{pname:'14 - 解脫',pauthor:'aaa',pcopyright:'bbb',pinfo:'cccc'}
arrurlvalue += " } " ;
var p = eval("(" + arrurlvalue+ ")" );
alert(p.pname);
[
[
{"id":0,"width":85.608,"top":0,"left":0,"oy":0,"name":"左侧窗口","ox":0,"height":240,"ms":0,"ex":0,"zindex":1200,"cursor":"","mt":0},
{"id":1,"width":96,"top":0,"left":144,"oy":0,"name":"右上窗口","ox":0,"height":120,"ms":0,"ex":0,"zindex":1201,"cursor":"","mt":0},
{"id":2,"width":96,"top":120,"left":144,"oy":0,"name":"右下窗口","ox":0,"height":120,"ms":0,"ex":0,"zindex":1202,"cursor":"","mt":0}
],
[
{"id":0,"width":240,"top":0,"left":0,"oy":0,"name":"上窗口","ox":0,"height":230.4,"ms":0,"ex":0,"zindex":1200,"cursor":"","mt":0},
{"id":1,"width":240,"top":230.4,"left":0,"oy":0,"name":"字幕窗口","ox":0,"height":9.6,"ms":0,"ex":0,"zindex":1201,"cursor":"","mt":0}
],
[
{"id":0,"width":240,"top":0,"left":0,"oy":0,"name":"满屏","ox":0,"height":240,"ms":0,"ex":0,"zindex":1200,"cursor":"","mt":0}
]
]
{[
{"i":1,"id":355,"bg":"","bgi":"","isdel":"0","tv":5,"d":3600,"p":0,"s":"","t":"音视","ds":"01:00:00","n":"Test File #9"},
{"i":1,"id":354,"bg":"","bgi":"","isdel":"0","tv":3,"d":3600,"p":100,"s":"","t":"图片","ds":"01:00:00","n":"q_2"},
{"i":2,"id":356,"bg":"","bgi":"","isdel":"0","tv":-3,"d":4027,"p":0,"s":"888","t":"直播","ds":"01:07:07","n":"888"}
]}
[{
persons:
[{name:"jordan",sex:"m",age:"40"},
{name:"bryant",sex:"m",age:"28"},
{name:"McGrady",sex:"m",age:"27"}
]
}]
有[ UserList[0].pname
var UserList = [
{pname:'14 - 解脫',pauthor:'aaa',pcopyright:'bbb',pinfo:'cccc',pduration:272,
chapter:
[
{pc_order:0,pc_duration:240,pc_program_id:533},
{pc_order:0,pc_duration:272,pc_program_id:533}
]
}
];
没有[ UserList.pname chapter: [{},{}]必须要[
var UserList =
{pname:'14 - 解脫',pauthor:'aaa',pcopyright:'bbb',pinfo:'cccc',pduration:272,
chapter:
[
{pc_order:0,pc_duration:240,pc_program_id:533},
{pc_order:0,pc_duration:272,pc_program_id:533}
]
};