Giter Site home page Giter Site logo

fast-json-parse's Introduction

fast-json-parse

Build Status

It is equivalent to json-parse-safe, but it set both the err and value property to null.

The reason why this is fast is that try/catch inhibits the functions in which you use them to be optimized. This assumption holds true up to Node 6, from Node 7 and forward this module is not useful anymore.

Install

npm i fast-json-parse --save

Usage

You can use it as a function or via a contructor, as you prefer.

function

'use strict'

var parse = require('fast-json-parse')
var fs = require('fs')

var result = parse(fs.readFileSync('./package.json', 'utf8'))

if (result.err) {
  console.log('unable to parse json', result.err.message)
} else {
  console.log('json parsed successfully', result.value)
}

constructor

'use strict'

var Parse = require('fast-json-parse')
var fs = require('fs')

var result = new Parse(fs.readFileSync('./package.json'))

if (result.err) {
  console.log('unable to parse json', result.err.message)
} else {
  console.log('json parsed successfully', result.value)
}

Acknowledgements

fast-json-parse is sponsored by nearForm.

License

MIT

fast-json-parse's People

Contributors

mcollina avatar emilbayes avatar marcbachmann avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.