better-json

0.3.8 • Public • Published

Better JSON

npm GitHub top language NPM

npm npm

paypal

Simply better json with comments and auto normalization. You can either use it as a new object, or override the default JSON object.

  • comments are removed from strings
  • quotes are added where needed automatically
  • single quotes are corrected to double, when needed
  • types are auto corrected ('1' becomes 1)
  • trailing commas are removed
  • crash resistance (runs in a try catch block, and returns null on error)

Installation

npm install @aspiesoft/better-json

Setup

const json = require('@aspiesoft/better-json');

// or to override the JSON object
require('@aspiesoft/better-json')();

Usage

json.parse(`
{
    option1: string,
    //option2: true, /* commented out */
    option3: true,
}
`);
// expected output: {option1: 'string', option3: true}

json.stringify({test: 2, unwantedFunction: function(){}});
// expected output: {"test": 2}

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i better-json

    Weekly Downloads

    14

    Version

    0.3.8

    License

    MIT

    Unpacked Size

    4.31 kB

    Total Files

    5

    Last publish

    Collaborators

    • aspiesoft