Javascript格式对象数据

时间:2014-06-20 19:47:14

标签: javascript csv

我有这样的数据(我通过执行console.log($ scope.exportData)得到它):

[Object, Object, Object, Object, Object]
0: Object
AdjustmentFactorsCustomerSatisfaction: -40
AdjustmentFactorsEmployeeCompetence: -30
AdjustmentFactorsStaffTurnovers: -50

你可以告诉我有5个对象,我希望为CSV文件格式化这些数据,因此每个值都是列名:AdjustmentFactorsCustomerSatisfaction,AdjustmentFactorsEmployeeCompetence,每个对象的数据为1行。我该怎么做我用于CSV的示例包含这样的数据,它可以工作:

var data = [["name1", "city1", "some other info"], ["name2", "city2", "more info"]];

它不返回列名。

这就是我想要的样子:

emergenciesGuidelines emergenciesGuidelines emergenciesGuidelines
(Object 1 data (-40)) (Object 1 data (-30))  (Object 1 data (-50))
(Object 2 data)       (Object 2 data)        (Object 2 data)

0 个答案:

没有答案