txt-to-json

1.0.0 • Public • Published

txt-to-json

txt-to-json is a simple script that converts txt files to JSON and outputs them in the core working directory. txt-to-json allows for full customization, letting you insert your own filter functions to determine keys and values.

Installation

Install via npm: npm install txt-to-json

Usage

const txtToJson = require('txt-to-json')
 
txtToJson('./data.txt')

Example input

key1:value1
key2:value2

Example output

{"key1":"value1","key2":"value2"}

Using line and key filters

If your keys are split by commas, and values by hyphens, use:

txtToJson('./data.txt', function (doc) {
    return doc.split(',')
}, function (line) {
    const [key, value] = line.split('-')
    return [key, value]
})

Readme

Keywords

Package Sidebar

Install

npm i txt-to-json

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

2.68 kB

Total Files

5

Last publish

Collaborators

  • soumil07