Skip to content

CLI Updates #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 36 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,40 +240,56 @@ $ npm install @mrodrig/json-2-csv-cli
```
Usage: json2csv <jsonFile> [options]

Arguments:
jsonFile JSON file to convert

Options:
-V, --version output the version number
-o, --output [output] Path of output file. If not provided, then stdout will be used
-f, --field <delimiter> Optional field delimiter
-w, --wrap <delimiter> Optional wrap delimiter
-e, --eol <delimiter> Optional end of line delimiter
-a, --array-indexes-as-keys Includes array indexes in the generated keys
-S, --check-schema Check for schema differences
-f, --field <delimiter> Field delimiter
-w, --wrap <delimiter> Wrap delimiter
-e, --eol <delimiter> End of Line delimiter
-E, --empty-field-value <value> Empty field value
-n, --expand-nested-objects Expand nested objects to be deep converted to CSV
-k, --keys [keys] Keys of documents to convert to CSV
-d, --escape-header-nested-dots Escape header nested dots
-b, --excel-bom Excel Byte Order Mark character prepended to CSV
-x, --exclude-keys [keys] Comma separated list of keys to exclude
-A, --expand-array-objects Expand array objects
-W, --without-header Withhold the prepended header
-p, --prevent-csv-injection Prevent CSV Injection
-s, --sort-header Sort the header fields
-H, --trim-header Trim header fields
-F, --trim-fields Trim field values
-S, --check-schema Check for schema differences
-E, --empty-field-value <value> Empty field value
-A, --expand-array-objects Expand array objects
-k, --keys [keys] Keys of documents to convert to CSV
-h, --help output usage information
-H, --trim-header Trim header fields
-U, --unwind-arrays Unwind array values to their own CSV line
-I, --iso-date-format Use ISO 8601 date format
-L, --locale-format Use locale format for values
-B, --wrap-booleans Wrap booleans
-h, --help display help for command
```

#### csv2json
```
Usage: csv2json <csvFile> [options]

Arguments:
csvFile CSV file to convert

Options:
-V, --version output the version number
-c, --csv <csv> Path of json file to be converted
-o, --output [output] Path of output file. If not provided, then stdout will be used
-f, --field <delimiter> Optional field delimiter
-w, --wrap <delimiter> Optional wrap delimiter
-e, --eol <delimiter> Optional end of line delimiter
-b, --excel-bom Excel Byte Order Mark character prepended to CSV
-H, --trim-header Trim header fields
-F, --trim-fields Trim field values
-k, --keys [keys] Keys of documents to convert to CSV
-h, --help output usage information
-V, --version output the version number
-o, --output [output] Path of output file. If not provided, then stdout will be used
-f, --field <delimiter> Field delimiter
-w, --wrap <delimiter> Wrap delimiter
-e, --eol <delimiter> End of Line delimiter
-b, --excel-bom Excel Byte Order Mark character prepended to CSV
-p, --prevent-csv-injection Prevent CSV Injection
-F, --trim-fields Trim field values
-H, --trim-header Trim header fields
-h, --header-fields Specify the fields names in place a header line in the CSV itself
-k, --keys [keys] Keys of documents to convert to CSV
--help display help for command
```

## Tests
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"name": "json-2-csv",
"description": "A JSON to CSV and CSV to JSON converter that natively supports sub-documents and auto-generates the CSV heading.",
"version": "5.5.3",
"version": "5.5.4",
"homepage": "https://mrodrig.github.io/json-2-csv",
"repository": {
"type": "git",
Expand Down
1 change: 0 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export const defaultCsv2JsonOptions: DefaultCsv2JsonOptions = {
preventCsvInjection: false,
trimFieldValues : false,
trimHeaderFields: false,
wrapBooleans: false,
};

export const excelBOM = '\ufeff';
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export interface DefaultCsv2JsonOptions extends
Pick<Csv2JsonOptions, 'headerFields'>,
Pick<Csv2JsonOptions, 'parseValue'>,
// Then extend the types with required fields and specific fields omitted:
Omit<Omit<Omit<BuiltCsv2JsonOptions, 'keys'>, 'headerFields'>, 'parseValue'> {}
Omit<Omit<Omit<Omit<BuiltCsv2JsonOptions, 'wrapBooleans'>, 'keys'>, 'headerFields'>, 'parseValue'> {}

export interface FullJson2CsvOptions extends DefaultJson2CsvOptions {
/**
Expand Down
Loading