| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
11年前发布

将JSON转换成CSV文件:json2csv

json2csv能够将JSON格式的数据转换成带标题的CSV格式文件。

特性:

  • Uses proper line endings on various operating systems
  • Handles double quotes
  • Allows custom column selection
  • Reads column selection from file
  • Pretty writing to stdout
  • Supports optional custom delimiters
  • Not create CSV column title by passing hasCSVColumnTitle: false, into params.
  • If field is not exist in object then the field value in CSV will be empty.

示例代码:

var json2csv = require('json2csv');    var json = [    {      "car": "Audi",      "price": 40000,      "color": "blue"    }, {      "car": "BMW",      "price": 35000,      "color": "black"    }, {      "car": "Porsche",      "price": 60000,      "color": "green"    }  ];    json2csv({data: json, fields: ['car', 'price', 'color']}, function(err, csv) {    if (err) console.log(err);    fs.writeFile('file.csv', csv, function(err) {      if (err) throw err;      console.log('file saved');    });  });

将JSON转换成CSV文件:json2csv

项目主页:http://www.open-open.com/lib/view/home/1388545050156

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1388545050156.html
json2csv JSON开发包