Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0.0 #24

Merged
merged 27 commits into from
Jun 6, 2017
Merged

v2.0.0 #24

merged 27 commits into from
Jun 6, 2017

Conversation

kaue
Copy link
Owner

@kaue kaue commented Jun 6, 2017

What's included?

var jsonexport = require('jsonexport');
var fs = require('fs');

var reader = fs.createReadStream('data.json');
var writer = fs.createWriteStream('out.csv');

reader.pipe(jsonexport()).pipe(writer);
var jsonexport = require('jsonexport');

var students = [
    {
      "name" : "John",
      "clases" : [
        {
          "year" : 2016,
          "grade" : "1st",
          "payment":[
            {
              "type":"monthly",
              "status":"done"
            },
            {
              "type":"yearly",
              "status":"done"
            }
          ]
        },
        {
          "year" : 2017,
          "grade" : "2nd",
          "payment":[
            {
              "type":"monthly",
              "status":"in progress"
            },
            {
              "type":"yearly",
              "status":"done"
            }
          ]
        }
      ],
      
    },
    {
      "name" : "Andrew",
      "clases" : [
        {
          "year" : 2017,
          "grade" : "1nd",
          "payment":[
            {
              "type":"monthly",
              "status":"in progress"
            },
            {
              "type":"yearly",
              "status":"in progress"
            }
          ]
        }
      ]
    },
    
  ]

jsonexport(students, {
   fillGaps: true
}, function(err, csv){
    if(err) return console.log(err);
    console.log(csv);
});
var jsonexport = require('jsonexport');

var contacts = [{
    name: 'Bob',
    lastname: 'Smith',
    address: {
       number: 1 
    }
},{
    name: 'James',
    lastname: 'David'
},{
    name: 'Robert',
    lastname: 'Miller'
},{
    name: 'David',
    lastname: 'Martin'
}];

jsonexport(contacts, {
   headers: ['lastname', 'name', 'address.number'] 
},function(err, csv){
    if(err) return console.log(err);
    console.log(csv);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants