2 u014603095 u014603095 于 2015.06.10 10:53 提问

从服务器获得这种数据之后,如何分别取出来进行处理?

[["2015-06-05 16:21:40","666"], ["2015-06-05 15:30:38","666"], ["2015-06-05 15:07:26","666"], ["2015-06-05 14:38:21","666"], ["2015-06-05 14:38:21","666"], ["2015-06-05 14:33:18","666"], ["2015-06-05 14:23:18","666"], ["2015-06-05 14:18:16","666"], ["2015-06-05 14:15:09","666"], ["2015-06-05 14:12:16","666"], ["2015-06-05 14:12:16","666"], ["2015-06-05 14:05:34","666"], ["2015-06-05 14:01:27","666"], ["2015-06-05 13:57:44","666"], ["2015-06-05 13:57:44","666"], ["2015-06-05 13:51:23","666"], ["2015-06-05 13:51:23","666"], ["2015-06-05 13:41:43","666"],]

(1)如何将这些数据取出来放到一个数组里?
(2)如何将单个的数据:["2015-06-05 13:41:43","666"]以“,”分隔取出来,例如:我要取出后面这个数据“666”

3个回答

showbo
showbo   Ds   Rxr 2015.06.10 11:06
已采纳

转为json对象就可以操作了,建议你最好将最后那个“,”去掉,搞标准点

     var s = '[["2015-06-05 16:21:40","666"], ["2015-06-05 15:30:38","666"], ["2015-06-05 15:07:26","666"], ["2015-06-05 14:38:21","666"], ["2015-06-05 14:38:21","666"], ["2015-06-05 14:33:18","666"], ["2015-06-05 14:23:18","666"], ["2015-06-05 14:18:16","666"], ["2015-06-05 14:15:09","666"], ["2015-06-05 14:12:16","666"], ["2015-06-05 14:12:16","666"], ["2015-06-05 14:05:34","666"], ["2015-06-05 14:01:27","666"], ["2015-06-05 13:57:44","666"], ["2015-06-05 13:57:44","666"], ["2015-06-05 13:51:23","666"], ["2015-06-05 13:51:23","666"], ["2015-06-05 13:41:43","666"],]';
    var o = eval('(' + s + ')');
    for (var i = 0; i < o.length; i++)
        alert(o[i][0] + '\n' + o[i][1]);
u010308285
u010308285   2015.06.10 11:07

json 截取,

xya_zone
xya_zone   2015.06.10 11:22

var s='[["2015-06-05 16:21:40","666"], ["2015-06-05 15:30:38","666"], ["2015-06-05 15:07:26","666"]......]';

var arr=eval('('+s+')');

for(var i=0;i<arr.length;i++){
alert(arr[i][1]);
}

Csdn user default icon
上传中...
上传图片
插入图片