prettyjson icon indicating copy to clipboard operation
prettyjson copied to clipboard

Question - Is there any way to use .pipe() in NodeJS with prettyjson

Open paulwehner opened this issue 9 years ago • 2 comments

So for example could I do something like:

var file = fs.createReadStream('dogs.json');
file.pipe(prettyjson.render).pipe(response);

paulwehner avatar Jul 20 '15 10:07 paulwehner

Using streams is not currently supported, as prettyjson decodes the whole JSON data at once.

Something similar to reading the process stdin could be done for streams.

rafeca avatar Aug 09 '15 12:08 rafeca

I guess this is related to support stdin output that is separated by newlines (such as JSONStream.stringify(false))?

Would be a great feature :-)

A current workaround using the JSONStream package: JSONStream < data.njs | prettyjson.

tjconcept avatar Aug 25 '16 18:08 tjconcept