json-to-txt
v2.1.1
Published
Reads JSON data (Array of objects) and returns a string in a txt file format.
Downloads
579
Maintainers
Readme
Reads JSON data (Array of objects) and returns a string in a txt file format.
Installation
npm i --save json-to-txt
Usage
json-to-txt
support CommonJS.
In module system
Use filePath
key to provide JSON data from file
.
const jsonToTxt = require("json-to-txt");
const dataInString = jsonToTxt({ filePath: "./filePath.json" });
Use data
key to provide JSON data from variable or directly
.
const jsonToTxt = require("json-to-txt");
const dataInString = jsonToTxt({ data: someJSONData });
Sample input (json data) :
[
{
NAME: {FIRST_NAME: 'Debra', LAST_NAME: 'Burks'},
NUMBER: '880012XXXX',
EMAIL: '[email protected]',
ADDRESS: '9273 Thome Ave., Orchard Park, NY - 14127'
},
{
NAME: {FIRST_NAME: 'Kasha', LAST_NAME: 'Todd'},
NUMBER: null,
EMAIL: '[email protected]',
ADDRESS: '910, Vine Street, Campbell, CA - 95008'
},
{
NAME: {FIRST_NAME: 'Tameka', LAST_NAME: 'Fisher'},
NUMBER: '880111XXXX',
EMAIL: '[email protected]',
ADDRESS: '7693 Honey Creek St., Redondo Beach, CA - 90278'
},
{
NAME: {FIRST_NAME: 'Daryl', LAST_NAME: 'Spence'},
NUMBER: '990015XXXX',
EMAIL: null,
ADDRESS: '988 Pearl Lane!!! (Uniondale), NY - 11553'
},
{
NAME: {FIRST_NAME: 'Charolette', LAST_NAME: 'Rice'},
NUMBER: '720012XXXX',
EMAIL: '[email protected]',
ADDRESS: '107 ~ River Dr. `Sacramento`, "CA" 95820'
}
]
Sample output (txt data) :
NAME NUMBER EMAIL ADDRESS
{ FIRST_NAME : Debra , LAST_NAME : Burks } 880012XXXX [email protected] 9273 Thome Ave., Orchard Park, NY - 14127
{ FIRST_NAME : Kasha , LAST_NAME : Todd } null [email protected] 910, Vine Street, Campbell, CA - 95008
{ FIRST_NAME : Tameka , LAST_NAME : Fisher } 880111XXXX [email protected] 7693 Honey Creek St., Redondo Beach, CA - 90278
{ FIRST_NAME : Daryl , LAST_NAME : Spence } 990015XXXX null 988 Pearl Lane!!! (Uniondale), NY - 11553
{ FIRST_NAME : Charolette , LAST_NAME : Rice } 720012XXXX [email protected] 107 ~ River Dr. `Sacramento`, "CA" 95820