Streaming JSON.stringify()
Similar to JSONStream.stringify() except it is, by default, a binary stream, and it is a streams2 implementation.
Example
The main use case for this is to stream a database query to a web client. This is meant to be used only with arrays, not objects.
var Stringify = app
will yield something like
Separators
- The stream always starts with
'[\n'
. - Documents are separated by
'\n,\n'
. - The stream is terminated with
'\n]\n'
.
Stringifier
By default, json-stringify-safe is used to convert objects into strings. This can be configured with options.stringifier
.
API
Stringify([options])
Returns a Transform
stream.
The options are passed to the Transform
constructor.
JSON.stringify options
You can override these:
var stringify = stringify {}stringifyspace = 2stringifyopener = '['stringifyseperator = ','stringifycloser = ']'stringifystringifier = JSONstringify