Skip to content

Commit

Permalink
feat: add arrayIndexesAsKeys option support for #207
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodrig committed Feb 25, 2024
1 parent 6fccca0 commit feeec3b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const errors = {
};

export const defaultJson2CsvOptions: DefaultJson2CsvOptions = {
arrayIndexesAsKeys: false,
checkSchemaDifferences: false,
delimiter : {
field : ',',
Expand Down
1 change: 1 addition & 0 deletions src/json2csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const Json2Csv = function(options: FullJson2CsvOptions) {
customValueParser = options.parseValue && typeof options.parseValue === 'function' ? options.parseValue : null,
expandingWithoutUnwinding = options.expandArrayObjects && !options.unwindArrays,
deeksOptions = {
arrayIndexesAsKeys: options.arrayIndexesAsKeys,
expandNestedObjects: options.expandNestedObjects,
expandArrayObjects: expandingWithoutUnwinding,
ignoreEmptyArraysWhenExpanding: expandingWithoutUnwinding,
Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ export interface Csv2JsonOptions extends Omit<SharedConverterOptions, 'keys'> {
}

export interface Json2CsvOptions extends SharedConverterOptions {
/** Should array indexes be included in the generated keys?
* @default false
*/
arrayIndexesAsKeys?: boolean;

/**
* Should all documents have the same schema?
* @default false
Expand Down

0 comments on commit feeec3b

Please sign in to comment.