Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何转换以下数据结构:
var data = [ [ { time: 1, speed : 20 } ] ];
到
var data = [ { time: 1, speed: 54 } ];
我只想删除数组。
由于数据是一个数组,您只想选择外部数组的第一个元素
所以解决方案是
var data = [[{time:1,speed:20}]]; // Or whatever the data is data = data[0];
或者,如果您正在通过另一个对象访问数据
var data = yourObject[0];
试试这个 :
JSON.stringify(data).substr(1,JSON.stringify(data).length-2);