现在有一串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]"
      },
    },求大神指导

解决方案 »

  1.   

    你那个什么字符串错误也太多了吧。自己对照吧"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)
      

  2.   

    json string =》 json 对象eval 函数 就 OK