js解析網路中的json資料

來源:互聯網
上載者:User

標籤:npoi   send   ima   location   art   dev   rip   nts   stop   

<?phpecho <<<_END<html><head></head><body><div id="container"></div><script> //var value2 = {"list":[ {"password":"1230","username":"coolcooldool"}, {"password":"thisis2","username":"okokok"}], "array":[{"password":"1230","username":"coolcooldool"},{"password":"thisis2","username":"okokok"}]};  // //var obj2 = eval(value2);  //alert(obj2.list[0].password);var getJSON = function(url) {      return new Promise(function(resolve, reject) {        var xhr = new XMLHttpRequest();        xhr.open(‘get‘, url, true);        xhr.responseType = ‘json‘;        xhr.onload = function() {          var status = xhr.status;          if (status == 200) {            resolve(xhr.response);          } else {            reject(status);          }        };        xhr.send();      });    };    getJSON(‘http://web.cellpies.com/api/driving/getVehicleLocationPoints?vehicleDeviceId=0400000000030603&timeType=4&startTime=2017-03-17%2013:00:00&stopTime=2017-03-17%2014:00:00‘).then(function(jdata) {        alert(‘Your Json result is:  ‘ + jdata); //you can comment this, i used it to debug        alert(jdata.data[0].gpsx);        alert(jdata.data[0].gpsy);                   }, function(status) { //error detection....      alert(‘Something went wrong.‘);    });</script> _END; ?>

json資料格式為


{
"retcode": 1,
"data": [
{
"time": "2017-03-17 13:15:00",
"longitudedegree": null,
"longitudeminute": null,
"longitudesecond": null,
"longitudedecimals": null,
"latitudedegree": null,
"latitudeminute": null,
"latitudesecond": null,
"latitudedecimals": null,
"gpsx": "126.60580555556",
"gpsy": "45.702363888889"
},
{
"time": "2017-03-17 13:15:01",
"longitudedegree": null,
"longitudeminute": null,
"longitudesecond": null,
"longitudedecimals": null,
"latitudedegree": null,
"latitudeminute": null,
"latitudesecond": null,
"latitudedecimals": null,
"gpsx": "126.60573055556",
"gpsy": "45.702355555556"
}
]
}

 

js解析網路中的json資料

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.