zll-json2csv 中文文档教程
json2csv.js
安装
npm install zll-json2csv
npm i zll-json2csv
使用
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);
输出
name,age,city
John,30,New York
Peter,40,Los Angeles
Amy,50,Chicago
json2csv.js
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