我有一个PHP API这个对象:获取从JSON对象中的数据在JavaScript
[Object { span=1, caption="Particular", master=true},
Object { span=5, caption="Loan Class 1"},
Object { span=5, caption="Loan Class 2"},
Object { span=5, caption="Loan Class 3"}]
所需的输出将是:
## Particular Loan Class 1 Loan Class 2 Loan Class 3 ##
我试着这样做:
var arrData = typeof JSONData != 'object' ? JSON.parse(JSONData) : JSONData;
for (var index in arrData[0]) {
row += index + ',';}
row = row.slice(0, -1);
CSV += row + '\r\n';
什么样的csv看起来像
## span caption master ##
请帮助如何获得标题值,如果有一个脚本,将在Excel中输出这个,因为需要添加一些列的合并。
向我们展示JSON,而不是print_r输出。 –