add flattenSeparator option (#40965)

This commit is contained in:
Denis
2019-12-16 12:21:05 +00:00
committed by Orta
parent 10a02498ea
commit f358375a37
3 changed files with 11 additions and 0 deletions
+1
View File
@@ -27,6 +27,7 @@ export declare namespace json2csv {
unwind?: string | Array<string>;
unwindBlank?: boolean;
flatten?: boolean;
flattenSeparator?: string;
defaultValue?: string;
quote?: string;
doubleQuote?: string;
+1
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/zemirco/json2csv
// Definitions by: Juanjo Diaz <https://github.com/juanjoDiaz>
// Daniel Gooß <https://github.com/dangoo>
// Denis Yilmaz <https://github.com/denisyilmaz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
+9
View File
@@ -86,6 +86,15 @@ try {
console.error(err);
}
// Test for Synchronous Parser with flatten and custom flattenSeparator
try {
const parser = new Parser<any>({ ...opts, flatten: true, flattenSeparator: ' / ' });
const csv = parser.parse({ car: '', price: 1, foo: { bar: '' } });
console.log(csv);
} catch (err) {
console.error(err);
}
// Test convenience method "parse"
try {
const csv = parse(data, opts);