SYNOPSIS
A very handy and narrowly scoped utility to take the output from JSONStream for piping into tools like jq.
Tools like jq
will otherwise hang waiting.
Basically it takes
\n"field": "value"\n\n"field": "value"\n... lots and lots of objects ...\n\n
and makes it into:
"field": "value"\n"field": "value"\n... lots and lots of objects ...
motivation
Let's say you have a very large source of JSON, maybe it's in a file; maybe it's something sending data over an http connection and that data has been piped through JSONStream
.
On the receiving end it looks like this:
"field": "value"... lots and lots of objects ...
Now if you pipe this directly to jq
it waits for the closing ]
before it'll start outputting the stream.
This made me sad.
USAGE
npm install -g j2ldj
curl localhost/big_json_response | j2ldj | jq '.'