#json

app streamson-bin

A program which processess large JSON input and splits them into a small ones

5 releases (3 stable)

✓ Uses Rust 2018 edition

new 1.0.2 Jul 2, 2020
1.0.1 Jun 28, 2020
1.0.0 Jun 25, 2020
0.2.0 May 29, 2020
0.1.0 May 19, 2020

#60 in Parser tooling

24 downloads per month

MIT license

87KB
2K SLoC

Streamson Bin

Splits stdout (in JSON format) according to given options. It is supposed to be memory efficient and fast to process.

Examples

Consider following context of input.json file:

{
	"books": [
		{"title": "title 1", "authors": ["author1@exmaple.com"]},
		{"title": "title 2", "authors": ["author2@example.com", "author3@example.com"]}
	]
}

Extract to stdout

cat input.json | streamson-bin -P '{"books"}[]'

Output:

{"books"}[0]: {"title": "title 1", "authors": ["author1@exmaple.com"]}
{"books"}[1]: {"title": "title 2", "authors": ["author2@example.com", "author3@example.com"]}

Extract to stdout without header

cat input.json | streamson-bin -p '{"books"}[]{"authors"}'

Output:

["author1@exmaple.com"]
["author2@example.com", "author3@example.com"]

Extract to file

cat input.json | streamson-bin -f '{"books"}[0]{}:/tmp/output.out'
cat /tmp/output.out

Output:

"title 1"
["author1@exmaple.com"]

Several matchers can be used

cat input.json | streamson-bin -p '{"books"}[]{"authors"}[]' -p '{"books"}[]{"title"}'

Output:

"title 1"
"author1@exmaple.com"
"title 2"
"author2@exmaple.com"
"author3@exmaple.com"

Dependencies

~0.7–1MB
~15K SLoC