Skip to content

Latest commit

 

History

History
49 lines (36 loc) · 1.54 KB

README.md

File metadata and controls

49 lines (36 loc) · 1.54 KB

j2ndj

goreleaser Go Report Card codecov Go Reference

Converts json to ndjson, New Line Delimited JSON.

Installation

# Install with go
go install github.com/do-i-need-a-username/j2ndj@latest

Usage

# find install path
which j2ndj
/Users/myuser/go/bin/j2ndj

# stdin t ostdout
cat input.json | ./bin/j2ndj
{"age":30,"city":"New York","name":"John Doe"}
{"age":28,"city":"Los Angeles","name":"Jane Doe"}
{"age":35,"city":"Chicago","name":"Bob Smith"}

# stdin to output file
cat input.json | ./bin/j2ndj -output=./output.ndjson

# input file to stdout
./bin/j2ndj -input=./input.json
{"age":30,"city":"New York","name":"John Doe"}
{"age":28,"city":"Los Angeles","name":"Jane Doe"}
{"age":35,"city":"Chicago","name":"Bob Smith"}

# input file to output file
./bin/j2ndj -input=./input.json -output=./output.ndjson

Alternative

Use jq to convert json to ndjson

jq -c '.[]' input.json > output.ndjson