1.0.2 • Published 7 years ago

web-stream-json-parser v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

web-stream-json-parser

A stream JSON parser based on web stream.

Install

$ npm i web-stream-json-parser -S

If you're using module bundler like webpack:

// ES6
import StreamParser from 'web-stream-json-parser';

// or CommonJS
var StreamParser = require('web-stream-json-parser');

Or you can include dist/stream-parser.umd.js to your html:

<script src="stream-parser.umd.js"></script>

You can find it on window.StreamParser

Usage

import StreamParser from 'web-stream-json-parser';

const parser = new StreamParser();

fetch('data.json').then(response => parser.parse(response.body));

// register your event
parser.on('string', str => {
    // do something
})

parser.on('onColon', () => {
    // do something
});

// ....more

EventList

EventStatus
numberFound and emit a number.
stringFound and emit a string.
booleanFound and emit a boolean.
nullFound and emit a null.
startObjectAn object started.
endObjectAn object ended.
startArrayAn array started.
endArrayAn array ended.
colonFound a colon.
commaFound a comma.

Examples & Demos

Please check web-stream-demos

Thanks for the event-only version of jsonparse from Tim Caswell