22 <a href =" http://runnerty.io " >
33 <img height="257" src="https://runnerty.io/assets/header/logo-stroked.png">
44 </a >
5- <p align =" center " >A new way for processes managing </p >
5+ <p align =" center " >Smart Processes Management </p >
66</p >
77
8- [ ![ NPM version] [ npm-image ]] [ npm-url ] [ ![ Downloads] [ downloads-image ]] [ npm-url ] [ ![ Dependency Status] [ david-badge ]] [ david-badge-url ]
8+ [ ![ NPM version] [ npm-image ]] [ npm-url ] [ ![ Downloads] [ downloads-image ]] [ npm-url ] [ ![ Dependency Status] [ david-badge ]] [ david-badge-url ]
99<a href =" #badge " >
10- <img alt =" code style: prettier " src =" https://img.shields.io/badge/code_style-prettier-ff69b4.svg " >
10+ <img alt =" code style: prettier " src =" https://img.shields.io/badge/code_style-prettier-ff69b4.svg " >
1111</a >
1212
1313# Executor for [ Runnerty] : JSON2CSV
1414
1515### Installation:
16+
17+ Through NPM
18+
1619``` bash
1720npm i @runnerty/executor-json2csv
1821```
1922
23+ You can also add modules to your project with [ runnerty-cli]
24+
25+ ``` bash
26+ npx runnerty-cli add @runnerty/executor-json2csv
27+ ```
28+
29+ This command installs the module in your project, adds example configuration in your ` config.json ` and creates an example plan of use.
30+
31+ If you have installed [ runnerty-cli] globally you can include the module with this command:
32+
33+ ``` bash
34+ rty add @runnerty/executor-json2csv
35+ ```
36+
2037### Configuration sample:
38+
39+ Add in [ config.json] :
40+
2141``` json
2242{
2343 "id" : " json2csv_default" ,
@@ -27,7 +47,10 @@ npm i @runnerty/executor-json2csv
2747
2848### Plan sample:
2949
50+ Add in [ plan.json] :
51+
3052#### JSON Example
53+
3154``` json
3255[
3356 {
@@ -62,32 +85,37 @@ npm i @runnerty/executor-json2csv
6285``` json
6386{
6487 "id" : " json2csv_default" ,
65- "inputPath" :" ./planets.json" ,
88+ "inputPath" : " ./planets.json" ,
6689 "outputPath" : " ./planets.csv"
6790}
6891```
92+
6993##### CSV Output
94+
7095```
7196"planet","radius","satellites"
7297"Earth",6371,"[{""name"":""moon"",""radius"":1737}]"
7398"Mars",3389,"[{""name"":""phobos"",""radius"":11267},{""name"":""deimos"",""radius"":6.2}]"
7499```
100+
75101#### Example 2:
102+
76103``` json
77104{
78105 "id" : " json2csv_default" ,
79- "inputPath" :" ./planets.json" ,
106+ "inputPath" : " ./planets.json" ,
80107 "outputPath" : " ./planets.csv" ,
81- "options" :{
108+ "options" : {
82109 "fields" : [" planet" , " radius" , " satellites.name" , " satellites.radius" ]
83110 },
84- "transforms" :{
111+ "transforms" : {
85112 "unwind" : { "paths" : [" satellites" ] }
86113 }
87114}
88115```
89116
90117##### CSV Ouput
118+
91119```
92120"planet","radius","satellites.name","satellites.radius"
93121"Earth",6371,"moon",1737
@@ -100,10 +128,10 @@ npm i @runnerty/executor-json2csv
100128``` json
101129{
102130 "id" : " json2csv_default" ,
103- "inputPath" : " ./input.json" ,
131+ "inputPath" : " ./input.json" ,
104132 "input" : " @GV(MY_JSON)" ,
105133 "outputPath" : " ./output.csv" ,
106- "options" :{
134+ "options" : {
107135 "fields" : [" field1" , " field2" , " field3" ],
108136 "defaultValue" : " NULL" ,
109137 "header" : true ,
@@ -114,45 +142,54 @@ npm i @runnerty/executor-json2csv
114142 "includeEmptyRows" : true ,
115143 "withBOM" : true
116144 },
117- "transforms" :{
118- "unwind" :{ "paths" : [" items" , " items.items" ], "blankOut" : true },
119- "flatten" :{ "objects" : true , "arrays" : true , "separator" : " _" }
145+ "transforms" : {
146+ "unwind" : { "paths" : [" items" , " items.items" ], "blankOut" : true },
147+ "flatten" : { "objects" : true , "arrays" : true , "separator" : " _" }
120148 }
121149}
122150```
151+
123152### Params
153+
124154#### Options
125- ```
126- fields List of fields to process. Defaults to field auto-detection.
127- defaultValue Default value to use for missing fields.
128- quote Character(s) to use as quote mark. Defaults to '"'.
129- escapedQuote Character(s) to use as a escaped quote. Defaults to a double `quote`, '""'.
130- delimiter Character(s) to use as delimiter. Defaults to ','. (default: ",")
131- eol Character(s) to use as End-of-Line for separating rows. Defaults to '\n'. (default: "\n")
132- excelStrings Wraps string data to force Excel to interpret it as string even if it contains a number.
133- header Boolean to Enable/Disable the column name header. (Enabled by defaults)
134- includeEmptyRows Boolean to Includes empty rows in the resulting CSV output.
135- withBOM Boolean to Includes BOM character at the beginning of the CSV.
136- ```
155+
156+ | Option | Description |
157+ | ---------------- | ----------------------------------------------------------------------------------------- |
158+ | fields | List of fields to process. Defaults to field auto-detection. |
159+ | defaultValue | Default value to use for missing fields. |
160+ | quote | Character(s) to use as quote mark. Defaults to '"'. |
161+ | delimiter | Character(s) to use as delimiter. Defaults to ','. (default: ",") |
162+ | escapedQuote | Character(s) to use as a escaped quote. Defaults to a double ` quote ` , '""'. |
163+ | eol | Character(s) to use as End-of-Line for separating rows. Defaults to '\n'. (default: "\n") |
164+ | excelStrings | Wraps string data to force Excel to interpret it as string even if it contains a number. |
165+ | header | Boolean to Enable/Disable the column name header. (Enabled by defaults) |
166+ | includeEmptyRows | Boolean to Includes empty rows in the resulting CSV output. |
167+ | withBOM | Boolean to Includes BOM character at the beginning of the CSV. |
168+
137169#### Transforms
138- ```
139- unwind Creates multiple rows from a single JSON document similar to MongoDB unwind.
140- paths Unwind fields path.
141- blankOut When unwinding, blank out instead of repeating data. Defaults to false. (default: false)
142- flatten Nested javascript objects into a single level object.
143- object Flatten nested objects. Defaults to false. (default: false)
144- arrays Flatten nested arrays. Defaults to false. (default: false)
145- separator Flattened keys separator. Defaults to '.'. (default: ".")
146- ```
170+
171+ | Option | Description |
172+ | ----------- | ---------------------------------------------------------------------------------------- |
173+ | unwind | Creates multiple rows from a single JSON document similar to MongoDB unwind. |
174+ | - paths | Unwind fields path. |
175+ | - blankOut | When unwinding, blank out instead of repeating data. Defaults to false. (default: false) |
176+ | flatten | Nested javascript objects into a single level object. |
177+ | - object | Flatten nested objects. Defaults to false. (default: false) |
178+ | - arrays | Flatten nested arrays. Defaults to false. (default: false) |
179+ | - separator | Flattened keys separator. Defaults to '.'. (default: ".") |
147180
148181### More information:
149- This executor is a wrapper of the module json2csv (zemirco), for more information consult the website of the [ json2csv] .
150182
183+ This executor is a wrapper of the module json2csv (zemirco), for more information consult the website of the [ json2csv] .
151184
152- [ Runnerty ] : http://www.runnerty.io
185+ [ runnerty ] : http://www.runnerty.io
153186[ downloads-image ] : https://img.shields.io/npm/dm/@runnerty/executor-json2csv.svg
154187[ npm-url ] : https://www.npmjs.com/package/@runnerty/executor-json2csv
155188[ npm-image ] : https://img.shields.io/npm/v/@runnerty/executor-json2csv.svg
156189[ david-badge ] : https://david-dm.org/runnerty/executor-json2csv.svg
157190[ david-badge-url ] : https://david-dm.org/runnerty/executor-json2csv
191+ [ config.json ] : http://docs.runnerty.io/config/
192+ [ plan.json ] : http://docs.runnerty.io/plan/
193+ [ ejs ] : https://ejs.co
194+ [ runnerty-cli ] : https://www.npmjs.com/package/runnerty-cli
158195[ json2csv ] : https://github.com/zemirco/json2csv
0 commit comments