serialize and escape quotes on nested objects when exporting as csv

This commit is contained in:
maxogden
2011-03-08 20:16:10 -08:00
parent d54b6a497c
commit f2a10600c0
3 changed files with 6 additions and 4 deletions

View File

@@ -18,7 +18,9 @@ function(head, req) {
for (var header in headers) {
if (row.value[headers[header]]) {
if (startedOutput) send(",");
send("\"" + row.value[headers[header]] + "\"");
var value = row.value[headers[header]];
if (typeof(value) == "object") value = JSON.stringify(value).replace(/"/g, '\\"');
send("\"" + value + "\"");
} else {
if (startedOutput) send(",");
}