New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

node-campaign

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

node-campaign

A campaign manager for NodeJS.

unpublished
latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

Convert JSON documents to CSV

This node module will convert an array of JSON documents to a CSV string.

Column headings will be automatically generated based on the keys of the JSON documents. Nested documents will have a '.' appended between the keys.

Installation

$ npm install json-2-csv

Usage

var json2csv = require('json-2-csv');

json2csv Example:


var json2csv = require('json-2-csv');

var documents = [
    {
        'Make': 'Nissan',
        'Model': 'Murano',
        'Year': '2013'
        'Specifications': {
            'Mileage': '7106',
            'Trim': 'S AWD'
        }
    },
    {
        'Make': 'BMW',
        'Model' 'X5',
        'Year': '2014',
        'Specifications': {
            'Mileage': '3287',
            'Trim': 'M'
        }
    }
];

var json2csvCallback = function (err, res) {
    if (err) throw err;
    console.log(res);
};

json2csv.json2csv(documents, json2csvCallback);

The above code prints out:

Make,Model,Year,Specifications.Mileage,Specifications.Trim
Nissan,Murano,2013,7106,S AWD
BMW,X5,2014,3287,M

Tests

TODO: Add tests

Features

  • Header Generation (per document keys)
  • Verifies all documents have same schema
  • Supports sub-documents natively
  • Custom ordering of columns (see F.A.Q. for more information)

F.A.Q.

  • Can the order of the keys be changed in the output? Yes. Currently, changing the order of the keys in the JSON document will also change the order of the columns. (Node 10.26)

Keywords

node

FAQs

Package last updated on 25 Apr 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts