Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

How to add second property at JSONStream.parse()? #107

Open
ghost opened this issue Sep 12, 2016 · 3 comments
Open

How to add second property at JSONStream.parse()? #107

ghost opened this issue Sep 12, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 12, 2016

I want to parse big json file and get from it two property how can i do this?
like i choose one
var parser = JSONStream.parse('email'), how can i add another one?

@ghost
Copy link
Author

ghost commented Sep 12, 2016

` var getStream = function () {

var stream = fs.createReadStream(fileName, {encoding: 'utf8'});
var parser = JSONStream.parse('email'); // how to add here another
return stream.pipe(parser);
};
getStream()
.pipe(es.mapSync(function (data) {
console.log(data);
}));
`
my code

@dominictarr
Copy link
Owner

JSONStream works best with list like data. Hopefully your json file is at some level, a very large array with many item.
you give JSONStream.parse(...) a path into the json object... maybe something like "rows.*.email" if you had a document that looked like {"rows": [....{email: foo@bar.com, ...}]}

if you need to get two properties, just take a path to the level they are in. say, rows.*

@ghost
Copy link
Author

ghost commented Sep 12, 2016

yeah, i do the same already, thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant