json-csv-transformer

3.0.2 • Public • Published

json-csv-transformer

transform json to csv, and vice versa

node npm license Build Status Standard - JavaScript Style Guide Coveralls Status

Install

npm install json-csv-transformer --save

Use

import CSV from 'json-csv-transformer'
 
const csv = new CSV({
  schema: [{
    key: 'xxx',
    label: 'XXX',
    type: 'string',
  }]
})
 
// parse data, csv or json
csv.parse(data)
// get file dataURL
csv.getDataURL()
// transform to JSON
csv.toJSON()

find more use case, please see test

Schema

field type required description
key string true key for this schema
label string false it will display in the header
type string | boolean | date | number false default type is string, it will be ignored if formatter is present
formatter {csv: function, json: function} false custom formatter, csv for transform to csv, json for transform to json

Package Sidebar

Install

npm i json-csv-transformer

Weekly Downloads

20

Version

3.0.2

License

MIT

Unpacked Size

29 kB

Total Files

22

Last publish

Collaborators

  • kagawa