jsonparse

repository·master·Indexed 18 days ago

https://github.com/creationix/jsonparse

A pure-js streaming JSON parser for node.js designed to process JSON data incrementally. It utilizes a Parser class that processes data in chunks via the .write(buffer) method, allowing for the handling of large JSON datasets that exceed available memory limits.

Tokens
313
Snippets
1
Records
2
Agent score
13%

What's inside jsonparse

  1. Use the Parser class to stream JSON data

    master

    The Parser class is a streaming JSON parser that processes data in chunks via the .write(buffer) method. To use it, you must extend the Parser class and override the onValue(value) method to receive parsed JSON values as they are completed.

    Because it is a streaming parser, it maintains internal state across multiple .write() calls, making it suitable for large JSON datasets that do not fit in memory.

    const Parser = require('./jsonparse');
    
    class MyParser extends Parser {
      onValue(value) {
        console.log('Parsed value:', value);
      }
    }
    
    const parser = new MyParser();
    
    // Feed chunks of data (Buffers or strings)
    parser.write(Buffer.from('{"key": "value", '));
    parser.write(Buffer.from('