[英]Angularjs json array nested object download to csv
After downloading into csv, i am getting this result, where the display setting is displaying [object Object] 下载到csv中后,我得到了这个结果,其中显示设置显示为[object Object]
How it should look like 它看起来像什么
My JS : 我的JS:
$scope.download = function () {
var csv = jsonToCsv(['ThemeName', 'DataSharing',
'DisplaySetting', 'ExpiryDate', 'Icon',
'PusblishDate','QueryName','ThemeName', 'ThemeOwner'], health)
var csvBlob = new Blob([csv], { type: 'text/csv' });
saveAs(csvBlob, 'json.csv');
};
May i ask how to modify the code so that it would show? 请问如何修改代码以使其显示出来? And also is it possible to choose what object I want to display in the csv file?
而且还可以选择要在csv文件中显示的对象? I would really really appreciate any help!
我真的很感谢您的帮助! I don't mind changing to another way of coding as long as it has the solution.
只要有解决方案,我就不介意改用另一种编码方式。 So, if you have any link which I can refer to would be really nice too.
因此,如果您有任何我可以引用的链接也将非常不错。 Thanks!
谢谢!
Stringify 字符串化
else if ($scope.all[i].CATEGORY == 'Health')
{
health.DISPLAY_SETTING =
JSON.stringify(health.DISPLAY_SETTING)
health.push($scope.all[i]);
}
在将其转换为csv之前,请尝试对health
内部的DisplaySetting
属性进行字符串化:
health.DisplaySetting = JSON.stringify(health.DisplaySetting);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.