json-updated

0.0.3 • Public • Published

Safe JSON parsing/stringifying using promises

Standard - JavaScript Style Guide

This tiny module provides a safe and modern way to parse or stringify JSON that uses type checking and promises.

I wrote this mini-module to more easily handle JSON within my projects.

Install & usage

Install it using npm:

npm install json-updated

You can use it anywhere you'd normally use the built-in JSON methods:

const updatedJSON = require('json-updated')
 
// Stringify an object:
updatedJSON.stringify({ an: 'object' }).then(str => {
  console.log(str)
}).catch(err => {
  console.log(err)
})
 
// Parse a string:
updatedJSON.parse('{ "some": "string" }').then(obj => {
  console.log(obj)
}).catch(err => {
  console.log(err)
})

This module now also ships with two simple methods for checking variable type. Both methods return a boolean:

// Check if an input is an object
updatedJSON.isObject(obj)
 
// Check if an input is a string
updatedJSON.isString(str)

License

Copyright 2016 Michiel van der Velde.

This software is licensed under the MIT License.

Readme

Keywords

Package Sidebar

Install

npm i json-updated

Weekly Downloads

0

Version

0.0.3

License

MIT

Last publish

Collaborators

  • michielvdvelde