convert-csv-to-json 3.20.0 → 3.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,27 +29,22 @@ jobs:
29
29
 
30
30
  release:
31
31
  needs: build
32
- permissions:
33
- id-token: write
34
32
  if: github.ref == 'refs/heads/master'
35
33
  name: release
36
34
  runs-on: ubuntu-latest
35
+ permissions:
36
+ contents: read
37
+ id-token: write
37
38
  steps:
38
39
  - uses: actions/checkout@v6
39
- with:
40
- token: ${{ secrets.ACTION_TOKEN }}
41
40
  - uses: fregante/setup-git-user@v2
42
41
  - run: git config --global user.name "dependabot"
43
- - name: Use Node.js 22.x
42
+ - name: Use Node.js 24.x
44
43
  uses: actions/setup-node@v6
45
44
  with:
46
- node-version: 22.x
45
+ node-version: 24.x
47
46
  registry-url: 'https://registry.npmjs.org'
48
47
  - name: npm-semver-publish
49
- uses: iuccio/npm-semver-publish-action@v1.11.0
50
- with:
51
- target-branch: 'master'
52
- provenance: true
53
- env:
54
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
48
+ run: |
49
+ npm run release
55
50
 
package/README.md CHANGED
@@ -21,6 +21,7 @@ This repository uses [![GitHub Action - iuccio/npm-semantic-publish-action@late
21
21
  Follow [me](https://github.com/iuccio), and consider starring the project to
22
22
  show your :heart: and support.
23
23
 
24
+
24
25
  ## Table of Contents
25
26
 
26
27
  <!-- toc -->
@@ -29,22 +30,22 @@ show your :heart: and support.
29
30
  - [Support for NodeJS, Browser, JS, TS](#support-for-nodejs-browser-js-ts)
30
31
  - [Prerequisites](#prerequisites)
31
32
  - [Install npm *convert-csv-to-json package*](#install-npm-convert-csv-to-json-package)
32
- * [Sync API Usage](#sync-api-usage)
33
- + [Generate JSON file](#generate-json-file)
34
- + [Generate Array of Object in JSON format](#generate-array-of-object-in-json-format)
35
- + [Generate Object with sub array](#generate-object-with-sub-array)
36
- + [Define field delimiter](#define-field-delimiter)
37
- + [Trim header field](#trim-header-field)
38
- + [Trim header field with whitespaces](#trim-header-field-with-whitespaces)
39
- + [Support Quoted Fields](#support-quoted-fields)
40
- + [Index header](#index-header)
41
- + [Empty rows](#empty-rows)
42
- + [Format property value by type](#format-property-value-by-type)
43
- - [Numbers](#numbers)
44
- - [Boolean](#boolean)
45
- - [Complete Example](#complete-example)
46
- + [Encoding](#encoding)
47
- + [Working with CSV strings directly](#working-with-csv-strings-directly)
33
+ - [Sync API Usage](#sync-api-usage)
34
+ * [Generate JSON file](#generate-json-file)
35
+ * [Generate Array of Object in JSON format](#generate-array-of-object-in-json-format)
36
+ * [Generate Object with sub array](#generate-object-with-sub-array)
37
+ * [Define field delimiter](#define-field-delimiter)
38
+ * [Trim header field](#trim-header-field)
39
+ * [Trim header field with whitespaces](#trim-header-field-with-whitespaces)
40
+ * [Support Quoted Fields](#support-quoted-fields)
41
+ * [Index header](#index-header)
42
+ * [Empty rows](#empty-rows)
43
+ * [Format property value by type](#format-property-value-by-type)
44
+ + [Numbers](#numbers)
45
+ + [Boolean](#boolean)
46
+ + [Complete Example](#complete-example)
47
+ * [Encoding](#encoding)
48
+ * [Working with CSV strings directly](#working-with-csv-strings-directly)
48
49
  * [Sync API (TypeScript)](#sync-api-typescript)
49
50
  - [Browser API Usage](#browser-api-usage)
50
51
  * [Basic Browser Operations](#basic-browser-operations)
@@ -145,9 +146,9 @@ Install package on your machine
145
146
  $ npm install -g convert-csv-to-json
146
147
  ```
147
148
 
148
- ### Sync API Usage
149
+ ## Sync API Usage
149
150
 
150
- #### Generate JSON file
151
+ ### Generate JSON file
151
152
  ```js
152
153
  let csvToJson = require('convert-csv-to-json');
153
154
 
@@ -156,7 +157,7 @@ let fileOutputName = 'myOutputFile.json';
156
157
 
157
158
  csvToJson.generateJsonFileFromCsv(fileInputName,fileOutputName);
158
159
  ```
159
- #### Generate Array of Object in JSON format
160
+ ### Generate Array of Object in JSON format
160
161
  ```js
161
162
  let csvToJson = require('convert-csv-to-json');
162
163
 
@@ -166,7 +167,7 @@ for(let i=0; i<json.length;i++){
166
167
  }
167
168
  ```
168
169
 
169
- #### Generate Object with sub array
170
+ ### Generate Object with sub array
170
171
  ```
171
172
  firstName;lastName;email;gender;age;birth;sons
172
173
  Constantin;Langsdon;clangsdon0@hc360.com;Male;96;10.02.1965;*diego,marek,dries*
@@ -193,7 +194,7 @@ The result will be:
193
194
  ]
194
195
  ```
195
196
 
196
- #### Define field delimiter
197
+ ### Define field delimiter
197
198
  A field delimiter is needed to split the parsed values. As default the field delimiter is the **semicolon** (**;**), this means that during the parsing when a **semicolon (;)** is matched a new JSON entry is created.
198
199
  In case your CSV file has defined another field delimiter you have to call the function ```fieldDelimiter(myDelimiter)``` and pass it as parameter the field delimiter.
199
200
 
@@ -204,11 +205,11 @@ E.g. if your field delimiter is the comma **,** then:
204
205
  .getJsonFromCsv(fileInputName);
205
206
  ```
206
207
 
207
- #### Trim header field
208
+ ### Trim header field
208
209
 
209
210
  The content of the field header is cut off at the beginning and end of the string. E.g. " Last Name " -> "Last Name".
210
211
 
211
- #### Trim header field with whitespaces
212
+ ### Trim header field with whitespaces
212
213
 
213
214
  Use the method *trimHeaderFieldWhiteSpace(true)* to remove the whitespaces in an header field (E.g. " Last Name " -> "LastName"):
214
215
 
@@ -217,7 +218,7 @@ Use the method *trimHeaderFieldWhiteSpace(true)* to remove the whitespaces in an
217
218
  .getJsonFromCsv(fileInputName);
218
219
  ```
219
220
 
220
- #### Support Quoted Fields
221
+ ### Support Quoted Fields
221
222
  To be able to parse correctly fields wrapped in quote, like the **last_name** in the first row in the following example:
222
223
 
223
224
  |first_name| last_name |email|
@@ -242,7 +243,7 @@ The result will be:
242
243
  ]
243
244
  ```
244
245
 
245
- #### Index header
246
+ ### Index header
246
247
  If the header is not on the first line you can define the header index like:
247
248
 
248
249
  ```js
@@ -250,10 +251,10 @@ If the header is not on the first line you can define the header index like:
250
251
  .getJsonFromCsv(fileInputName);
251
252
  ```
252
253
 
253
- #### Empty rows
254
+ ### Empty rows
254
255
  Empty rows are ignored and not parsed.
255
256
 
256
- #### Format property value by type
257
+ ### Format property value by type
257
258
  The `formatValueByType()` function intelligently converts string values to their appropriate types while preserving data integrity. To enable automatic type conversion:
258
259
 
259
260
  ```js
@@ -263,7 +264,7 @@ csvToJson.formatValueByType()
263
264
 
264
265
  This conversion follows these rules:
265
266
 
266
- ##### Numbers
267
+ #### Numbers
267
268
  - Regular integers and decimals are converted to Number type
268
269
  - Numbers with leading zeros are preserved as strings (e.g., "0012" stays "0012")
269
270
  - Large integers outside JavaScript's safe range are preserved as strings
@@ -279,7 +280,7 @@ For example:
279
280
  }
280
281
  ```
281
282
 
282
- ##### Boolean
283
+ #### Boolean
283
284
  Case-insensitive "true" or "false" strings are converted to boolean values:
284
285
  ```json
285
286
  {
@@ -288,7 +289,7 @@ Case-insensitive "true" or "false" strings are converted to boolean values:
288
289
  }
289
290
  ```
290
291
 
291
- ##### Complete Example
292
+ #### Complete Example
292
293
  Input CSV:
293
294
  ```csv
294
295
  first_name;last_name;email;gender;age;id;zip;registered
@@ -322,7 +323,7 @@ Output JSON:
322
323
  ]
323
324
  ```
324
325
 
325
- #### Encoding
326
+ ### Encoding
326
327
  You can read and decode files with the following encoding:
327
328
  * utf8:
328
329
  ```js
@@ -360,7 +361,7 @@ You can read and decode files with the following encoding:
360
361
  .getJsonFromCsv(fileInputName);
361
362
  ```
362
363
 
363
- #### Working with CSV strings directly
364
+ ### Working with CSV strings directly
364
365
  If you have CSV content as a string (for example, from an API response or test data), you can parse it directly without writing to a file:
365
366
 
366
367
  ```js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "convert-csv-to-json",
3
- "version": "3.20.0",
3
+ "version": "3.22.0",
4
4
  "description": "Convert CSV to JSON",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -49,5 +49,9 @@
49
49
  "ts-jest": "^29.4.5",
50
50
  "typescript": "^5.9.3",
51
51
  "@types/jest": "^30.0.0"
52
+ },
53
+ "publishConfig": {
54
+ "provenance": true,
55
+ "access": "public"
52
56
  }
53
57
  }
@@ -32,7 +32,7 @@ npm_release(){
32
32
  npm version minor --force -m "${RELEASE_COMMIT_MSG}";
33
33
  fi
34
34
  echo "Publish new version..."
35
- npm publish;
35
+ npm publish --provenance --access public ;
36
36
  echo "Publish git info...";
37
37
  git push --follow-tags
38
38
  echo "New version successfully published."
@@ -45,4 +45,4 @@ execute-new-release(){
45
45
  echo "End Semantic Versioning release.";
46
46
  }
47
47
 
48
- execute-new-release;
48
+ execute-new-release;