json-parse-async
The missing JSON.parse async interface.
Install
npm install json-parse-async --save
If you want to use in the browser (powered by Browserify):
bower install json-parse-async --save
and later link in your HTML:
<script src="bower_components/json-parse-async/dist/json-parse-async.js"></script>
Usage
var parseJSON = require('json-parse-async');
var stringify = '{"foo":"bar"}';
// as callback interface
parseJSON(stringify, function(err, content) {
console.log(content.foo); // => 'bar'
});
// as promise interface
parseJSON(stringify)
.then(function(content) {
console.log(content.foo); // => 'bar'
})
.catch(function(err) {
console.log('promise was rejected:', err);
});
License
MIT © Kiko Beats