现在有一串array:
"name":"ns1:timeSeriesResponseType","declaredType","org.cuahsi.waterml.TimeSeriesResponseType","scope" : "javax.xml.bind.JAXBElement$GlobalScope", "value" : {"queryInfo" : {"creationTime" : 1352391617000, "queryURL" : "http://waterservices.usgs.gov/nwis/iv/","criteria" :"locationParam" : "[ALL:01658000]","variableParam" : "[00060, 00065]"},},
请问怎么把它转换成object类型
最后成这样:
"name" : "ns1:timeSeriesResponseType",
"declaredType" : "org.cuahsi.waterml.TimeSeriesResponseType",
"scope" : "javax.xml.bind.JAXBElement$GlobalScope",
"value" : {
"queryInfo" : {
"creationTime" : 1352391617000,
"queryURL" : "http://waterservices.usgs.gov/nwis/iv/",
"criteria" : {
"locationParam" : "[ALL:01658000]",
"variableParam" : "[00060, 00065]"
},
},求大神指导
"name":"ns1:timeSeriesResponseType","declaredType","org.cuahsi.waterml.TimeSeriesResponseType","scope" : "javax.xml.bind.JAXBElement$GlobalScope", "value" : {"queryInfo" : {"creationTime" : 1352391617000, "queryURL" : "http://waterservices.usgs.gov/nwis/iv/","criteria" :"locationParam" : "[ALL:01658000]","variableParam" : "[00060, 00065]"},},
请问怎么把它转换成object类型
最后成这样:
"name" : "ns1:timeSeriesResponseType",
"declaredType" : "org.cuahsi.waterml.TimeSeriesResponseType",
"scope" : "javax.xml.bind.JAXBElement$GlobalScope",
"value" : {
"queryInfo" : {
"creationTime" : 1352391617000,
"queryURL" : "http://waterservices.usgs.gov/nwis/iv/",
"criteria" : {
"locationParam" : "[ALL:01658000]",
"variableParam" : "[00060, 00065]"
},
},求大神指导
红色的是修正的,蓝色的是删除的
function toObject(a){
return (new Function('return ' + a))();
}
var str='"name":"ns1:timeSeriesResponseType","declaredType":"org.cuahsi.waterml.TimeSeriesResponseType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"queryInfo":{"creationTime":1352391617000,"queryURL":"http://waterservices.usgs.gov/nwis/iv/","criteria":{"locationParam":"[ALL:01658000]","variableParam":"[00060,00065]"}}}';
var json=toObject('{'+str+'}');
alert(json.name)