1.0.3 • Published 1 year ago

zll-json2csv v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

json2csv.js

License GitHub file size in bytes npm

Installation

npm install zll-json2csv
npm i zll-json2csv

Usage

const json2csv = require('zll-json2csv');

// Create a JSON array
const json = [
    {
        name: "John",
        age: 30,
        city: "New York"
    },
    {
        name: "Peter",
        age: 40,
        city: "Los Angeles"
    },
    {
        name: "Amy",
        age: 50,
        city: "Chicago"
    }
];

// Convert JSON array to CSV string
const csv = json2csv(json);

// Print CSV string
console.log(csv);

Output

name,age,city
John,30,New York
Peter,40,Los Angeles
Amy,50,Chicago