当前位置: 动力学知识库 > 问答 > 编程问答 >

Javascript array of objects specific format

问题描述:

I got an array of objects and I want to display it like:

data: [

{ year: '2008', value: 20 },

{ year: '2009', value: 10 },

{ year: '2010', value: 5 },

{ year: '2011', value: 5 },

{ year: '2012', value: 20 }

],

I need this to use it for morris.js, but I can't do it manually like object[0] because I dont know the total length of the array.

Is there any way to get these format from this one?

Array [ Object ]

网友答案:

set your array as the data objct i.e. data:yourarray

分享给朋友:
您可能感兴趣的文章:
随机阅读: