You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.
So, there are no arrays, but just a massive nested object.
I'd like to stream it in, parse it, and write the results to a new JSON.
So far, this is what I've come up w/:
// write all objects with a path that matches '/*/images/'
var writeStream = fs.createWriteStream('home-images.json')
var readStream = fs.createReadStream('homes.json')
readStream
.pipe(JSONStream.parse([true, 'images', {emitKey: true}]))
.pipe(writeStream)
But as you may have guessed, this is just making it rain errors.
ypeError: Invalid non-string/buffer chunk
at validChunk (_stream_writable.js:216:10)
at WriteStream.Writable.write (_stream_writable.js:245:12)
at Stream.ondata (stream.js:31:26)
at emitOne (events.js:96:13)
at Stream.emit (events.js:188:7)
at drain (/home/bmp/code/wayhome/database-utils/node_modules/through/index.js:36:16)
at Stream.stream.queue.stream.push (/home/bmp/code/wayhome/database-utils/node_modules/through/index.js:45:5)
at Parser.parser.onValue (/home/bmp/code/wayhome/database-utils/node_modules/JSONStream/index.js:103:16)
at Parser.proto.emit (/home/bmp/code/wayhome/database-utils/node_modules/jsonparse/jsonparse.js:265:8)
at Parser.proto.pop (/home/bmp/code/wayhome/database-utils/node_modules/jsonparse/jsonparse.js:260:8)
The text was updated successfully, but these errors were encountered:
I had to do something similar with this library and it worked well. The only thing is that JSONStram.stringify() writes an array of objects, which wasn't an issue for me.
Here's what I would try:
// write all objects with a path that matches '/*/images/'
var writeStream = fs.createWriteStream('home-images.json')
var readStream = fs.createReadStream('homes.json')
readStream
.pipe(JSONStream.parse([true, 'images', {emitKey: true}]))
.pipe(JSONStream.stringify())
.pipe(writeStream)
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Haven't worked too much with streams & having some trouble understanding this
API
--anyone have some good examples they can point to?my use case is pretty simple. I have a giant single-object
JSON
, ie,So, there are no arrays, but just a massive nested object.
I'd like to stream it in, parse it, and write the results to a new
JSON
.So far, this is what I've come up w/:
But as you may have guessed, this is just making it rain errors.
The text was updated successfully, but these errors were encountered: