Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

txt-to-json

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

txt-to-json

Simple script that reads txt files and outputs their JSON equivalent.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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]
})

Keywords

FAQs

Package last updated on 01 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc