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

@ -11,8 +11,7 @@
<script type="text/javascript">
$(function() {
var name,
baseURL = "_rewrite/",
var baseURL = "_rewrite/",
vhost = false;
if (document.location.pathname.indexOf("_design") == -1) {
@ -32,6 +31,7 @@
}
function gotDb(dbInfo) {
render('db', 'stats', dbInfo);
var data = {

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(",");
}

View File

@ -21,7 +21,7 @@
},
{
"to": "_list/csv/all",
"from": "*.csv"
"from": "csv"
},
{
"to": "_list/urlencode/headers",