Skip to content

NickOver/csv2json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

csv2json

It's a simple liblary to convert csv to json string.

Simple usage

    $csv = file_get_content('example.csv');
    require_once('csv2json.php');
    $obj = new csv2json();
    $json = $obj->getJson($csv);

You can change confing by typing:

    $obj->setValue('fieldSeparator', ';');

Or by giving config array in constructior:

    $configArray = array(
        'fieldsSeparator'   =>  ';',
        'firstRowAsKey'     =>  false
    );
    $obj = new csv2json($configArray);

Avalible config values:

  • (string)fieldSeparator - field separator - default ','
  • (string)rowSeparator - row separator - default ';'
  • (string)avoidFieldsNumber - fields that will be omitted when generating, separated by comma - default 'none'
  • (boolean)firstRowAsKey - if true first csv line will be used as values keys - default 'true'

About

Simple library to convert csv to json format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages