https://github.com/dweinstein/j2ldj
A very handy and narrowly scoped node utility to take the output from JSONStream for piping into tools like jq.
https://github.com/dweinstein/j2ldj
Last synced: about 2 months ago
JSON representation
A very handy and narrowly scoped node utility to take the output from JSONStream for piping into tools like jq.
- Host: GitHub
- URL: https://github.com/dweinstein/j2ldj
- Owner: dweinstein
- License: mit
- Created: 2015-08-28T20:53:55.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-30T21:51:27.000Z (over 9 years ago)
- Last Synced: 2025-02-25T12:40:12.135Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 156 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SYNOPSIS
A very handy and narrowly scoped utility to take the output from [JSONStream](https://github.com/dominictarr/JSONStream) for piping into tools like [jq](https://github.com/stedolan/jq).
Tools like `jq` will otherwise hang waiting.
Basically it takes
```javascript
[\n
{"field": "value"}\n
,\n
{"field": "value"}\n
... lots and lots of objects ...
,\n
]\n
```and makes it into:
```javascript
{"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:
```javascript
[
{"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
```sh
npm install -g j2ldj
``````sh
curl localhost/big_json_response | j2ldj | jq '.'
```