json-cat-parser
Version:
concatenated json parser
33 lines (21 loc) • 798 B
Markdown
concatenated json parser
Read chunks of json as they become available
```
import getParser from 'json-cat-parser';
const outputStream = await getParser("http://www.someLocation.com", {
itemArrayElementName: "results"
});
const outputArrays = [];
outputStream.on("data", outputChunk => {
const itemsArray = JSON.parse(arrayBufferToString(outputChunk));
outputArrays.push(...itemsArray);
// do whatever processing you need to for the entities returned
});
outputStream.on("end", () => {
// anything you need to do when the request completed
});
```
the config parameter to `getParser` currently only has the `itemArrayElementName` property. This property tells the parser where to locate the array of entities that it should parse.