json-updated

json-updated JS library on GitHub json-updated JS library on npm Download json-updated JS library

[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)

Version 0.0.3 License MIT
json-updated has no homepage
json-updated JS library on GitHub
json-updated JS library on npm
Download json-updated JS library
Keywords
jsonstringifyparse

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.