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
If a user listens for 'data' events on an Oboe instance, the chunk contains the original request data, not the transformed JSON. This functionality would be very helpful with large JSON files, or when scraping data with libraries such as x-ray.
// based on http://oboejs.com/examples#transforming-json-while-it-is-streaming
const oboe = require("oboe");
const fs = require('fs');
const stream = fs.createReadStream('./example.json');
function toLower(s){
return s.toLowerCase();
}
const oboeStream = oboe(stream)
.node('verb', toLower)
.node('noun', toLower)
.node('!.*', function(pair) {
console.log('Please', pair.verb, 'me some', pair.noun);
});
// oboe's 'data' events do not contain the transformed JSON
oboeStream.on('data', chunk => {
console.log(chunk);
});
Output:
Note that JSON data is not transformed.
[
{"verb":"VISIT", "noun":"SHOPS"},
{"verb":"FIND", "noun":"WINE"},
{"verb":"MAKE", "noun":"PIZZA"}
]
Please visit me some shops
Please find me some wine
Please make me some pizza
The text was updated successfully, but these errors were encountered:
If a user listens for 'data' events on an Oboe instance, the chunk contains the original request data, not the transformed JSON. This functionality would be very helpful with large JSON files, or when scraping data with libraries such as x-ray.
Code from example:
Output:
The text was updated successfully, but these errors were encountered: