Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bennu-json

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bennu-json

A JSON parser for Bennu.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

bennu-json

This is a JSON parser for the Bennu parser combinator library. This module is good for:

  • working in places where the native JSON.parse function is not available (though other polyfills may be more performant).
  • parsing JSON incrementally.
  • being an example of how to use parser combinators and the Bennu library.

Usage

This module exports parsers for json, array, object, number, and string. Using the json parser to parse strings into objects requires using the Bennu library.

var bennu = require('bennu');
var json = require('bennu-json').json;

function jsonParse(str) {
  return bennu.parse.run(
    bennu.lang.then(json, bennu.parse.eof),
    str.trim()
  );
}

console.log(jsonParse('{"a": [-5.12e100, null]}'));
// { a: [ -5.12e+100, null ] }

You can also do incremental parsing with Bennu:

var bennu = require('bennu');
var json = require('bennu-json').json;

var s1 = bennu.incremental.runInc(bennu.lang.then(json, bennu.parse.eof));
var s2 = bennu.incremental.provideString('[123,45', s1);
var s3 = bennu.incremental.provideString('6,789]', s2);
console.log(bennu.incremental.finish(s3));
// [ 123, 456, 789 ]

Keywords

FAQs

Package last updated on 06 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc