mpp-server-dev2/node_modules/node-json-color-stringify
Hri7566 7051cfd9da add dotenv 2021-03-20 19:12:38 +00:00
..
examples add dotenv 2021-03-20 19:12:38 +00:00
img add dotenv 2021-03-20 19:12:38 +00:00
.npmignore add dotenv 2021-03-20 19:12:38 +00:00
LICENSE.md add dotenv 2021-03-20 19:12:38 +00:00
README.MD add dotenv 2021-03-20 19:12:38 +00:00
index.js add dotenv 2021-03-20 19:12:38 +00:00
package.json add dotenv 2021-03-20 19:12:38 +00:00

README.MD

node-json-color-stringify

Add a colorized version of JSON.stringify to JSON for console (Compatible with Windows and UNIX like systems).

Features

screenshot macOS

node-json-color-stringify offers an alternative method to replace JSON.stringify method by a new one that highlights JSON content for console output.

Install

npm install --save node-json-color-stringify

Usage

Colorized version is available as JSON.colorStringify:

require('node-json-color-stringify');
console.log(JSON.colorStringify({string: 'foo', nullElement: null, bool: false, integer: 42, array: ['Foo', 'bar']}));

Import node-json-color-stringify and use JSON.stringify as usual for non-colorized object output:

require('node-json-color-stringify');
console.log(JSON.stringify({string: 'foo', nullElement: null, bool: false, integer: 42, array: ['Foo', 'bar']}));

Replace array or function are also available:

require('node-json-color-stringify');
console.log(JSON.colorStringify(data, ['nullElement'], 2));
console.log(JSON.colorStringify(data, (key, value) => {
  if (key === 'string') {
    return undefined;
  } else if (value === null) {
    return 0; 
  }
  return value;
}, 2));

Contributing

Contributions welcome; Please submit all pull requests against the master branch. If your pull request contains JavaScript patches or features, you should include relevant unit tests.

Author

René BIGOT

License