<commit_before># jsonexport
This module makes easy to convert JSON to CSV and its very customizable.

#Usage
Installation command is `npm install jsonexport`.

```js

    var jsonexport = require('jsonexport');

    jsonexport({lang: 'Node.js',module: 'jsonexport'}, {rowDelimiter: '|'}, function(err, csv){
        if(err) return console.log(err);
        console.log(csv);
    });
```

##JSON Array Example

###Simple Array
####Code

```js

    var jsonexport = require('jsonexport');

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

    jsonexport(contacts,function(err, csv){
        if(err) return console.log(err);
        console.log(csv);
    });

```

####Result
    name;lastname
    Bob;Smith
    James;David
    Robert;Miller
    David;Martin


###Complex Array
####Code
```js

    var jsonexport = require('jsonexport');

    var contacts = [{
       name: 'Bob',
       lastname: 'Smith',
       family: {
           name: 'Peter',
           type: 'Father'
       }
    },{
       name: 'James',
       lastname: 'David',
       family:{
           name: 'Julie',
           type: 'Mother'
       }
    },{
       name: 'Robert',
       lastname: 'Miller',
       family: null,
       location: [1231,3214,4214]
    },{
       name: 'David',
       lastname: 'Martin',
       nickname: 'dmartin'
    }];

    jsonexport(contacts,function(err, csv){
        if(err) return console.log(err);
        console.log(csv);
    });

```
####Result
    lastname;name;family.type;family.name;nickname;location
    Smith;Bob;Father;Peter;;
    David;James;Mother;Julie;;
    Miller;Robert;;;;1231,3214,4214
    Martin;David;;;dmartin;

##JSON Object Example

###Simple Object
####Code

```js

    var jsonexport = require('jsonexport');

    var stats = {
        cars: 12,
        roads: 5,
        traffic: 'slow'
    };

    jsonexport(stats,function(err, csv){
        if(err) return console.log(err);
        console.log(csv);
    });

```

####Result
    cars;12
    roads;5
    traffic;slow

###Complex Object
####Code

```js

    var jsonexport = require('jsonexport');

    var stats = {
        cars: 12,
        roads: 5,
        traffic: 'slow',
        speed: {
            max: 123,
            avg: 20,
            min: 5
        },
        size: [10,20]
    };

    jsonexport(stats,function(err, csv){
        if(err) return console.log(err);
        console.log(csv);
    });
```

####Result
    cars;12
    roads;5
    traffic;slow
    speed.max;123
    speed.avg;20
    speed.min;5
    size;10,20

##Customization
In order to get the most of out of this module, you can customize many parameters, check the list:

    Option : Default Value
    headerPathString: '.',
    rowDelimiter: ';',
    endOfLine: null,
    mainPathItem: null,
    arrayPathString: ',',
    booleanTrueString: null,
    booleanFalseString: null,
    includeHeaders: true,
    orderHeaders: true,
    undefinedString: '',
    verticalOutput: true,
    handleString: null,
    handleNumber: null,
    handleBoolean: null,
    handleDate: null,
    handleArray: null,
    handleObject: null

###Handle Customization
Lets say you want to prepend a text to every string in your CSV file, how to do it?

```js

    var jsonexport = require('jsonexport');

    var options = {
        handleString: function(string, name){
            return 'Hey - ' + string;
        }
    };

    jsonexport({lang: 'Node.js',module: 'jsonexport'}, options, function(err, csv){
        if(err) return console.log(err);
        console.log(csv);
    });
```

The output would be:

    lang;Hey - Node.js
    module;Hey - jsonexport
<commit_msg>readme format fix<commit_after># jsonexport
This module makes easy to convert JSON to CSV and its very customizable.

#Usage
Installation command is `npm install jsonexport`.

```js
var jsonexport = require('jsonexport');

jsonexport({lang: 'Node.js',module: 'jsonexport'}, {rowDelimiter: '|'}, function(err, csv){
    if(err) return console.log(err);
    console.log(csv);
});
```

##JSON Array Example

###Simple Array
####Code

```js
var jsonexport = require('jsonexport');

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

jsonexport(contacts,function(err, csv){
    if(err) return console.log(err);
    console.log(csv);
});
```

####Result
    name;lastname
    Bob;Smith
    James;David
    Robert;Miller
    David;Martin


###Complex Array
####Code
```js
var jsonexport = require('jsonexport');

var contacts = [{
   name: 'Bob',
   lastname: 'Smith',
   family: {
       name: 'Peter',
       type: 'Father'
   }
},{
   name: 'James',
   lastname: 'David',
   family:{
       name: 'Julie',
       type: 'Mother'
   }
},{
   name: 'Robert',
   lastname: 'Miller',
   family: null,
   location: [1231,3214,4214]
},{
   name: 'David',
   lastname: 'Martin',
   nickname: 'dmartin'
}];

jsonexport(contacts,function(err, csv){
    if(err) return console.log(err);
    console.log(csv);
});
```
####Result
    lastname;name;family.type;family.name;nickname;location
    Smith;Bob;Father;Peter;;
    David;James;Mother;Julie;;
    Miller;Robert;;;;1231,3214,4214
    Martin;David;;;dmartin;

##JSON Object Example

###Simple Object
####Code

```js
var jsonexport = require('jsonexport');

var stats = {
    cars: 12,
    roads: 5,
    traffic: 'slow'
};

jsonexport(stats,function(err, csv){
    if(err) return console.log(err);
    console.log(csv);
});
```

####Result
    cars;12
    roads;5
    traffic;slow

###Complex Object
####Code

```js
var jsonexport = require('jsonexport');

var stats = {
    cars: 12,
    roads: 5,
    traffic: 'slow',
    speed: {
        max: 123,
        avg: 20,
        min: 5
    },
    size: [10,20]
};

jsonexport(stats,function(err, csv){
    if(err) return console.log(err);
    console.log(csv);
});
```

####Result
    cars;12
    roads;5
    traffic;slow
    speed.max;123
    speed.avg;20
    speed.min;5
    size;10,20

##Customization
In order to get the most of out of this module, you can customize many parameters, check the list:

    Option : Default Value
    headerPathString: '.',
    rowDelimiter: ';',
    endOfLine: null,
    mainPathItem: null,
    arrayPathString: ',',
    booleanTrueString: null,
    booleanFalseString: null,
    includeHeaders: true,
    orderHeaders: true,
    undefinedString: '',
    verticalOutput: true,
    handleString: null,
    handleNumber: null,
    handleBoolean: null,
    handleDate: null,
    handleArray: null,
    handleObject: null

###Handle Customization
Lets say you want to prepend a text to every string in your CSV file, how to do it?

```js
var jsonexport = require('jsonexport');

var options = {
    handleString: function(string, name){
        return 'Hey - ' + string;
    }
};

jsonexport({lang: 'Node.js',module: 'jsonexport'}, options, function(err, csv){
    if(err) return console.log(err);
    console.log(csv);
});
```

The output would be:

    lang;Hey - Node.js
    module;Hey - jsonexport

{'fraction_non_alphanumeric': 0.1511452475654917, 'fraction_numerical': 0.015361404471265945, 'mean_word_length': 2.7052845528455283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6972335', 'n_tokens_mistral': 2637, 'n_tokens_neox': 2439, 'n_words': 600}