Code Monkey home page Code Monkey logo

node-json-color-stringify's Introduction

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

node-json-color-stringify's People

Contributors

renebigot avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

shabanovtg kroid

node-json-color-stringify's Issues

Cannot use this from typescript

Typescript requires a .d.ts file which describes how to typecheck.

From https://stackoverflow.com/a/12695001/1027568 I learned that this could be initially generated using dts, so I did and it gave me this node-json-color-stringify.d.ts:

/** Declaration file generated by dts-gen */

export function colorStringify(obj: any, filter: any, indent: any, level: any): any;

export function parse(p0: any, p1: any): any;

export function stringify(p0: any, p1: any, p2: any): any;

export namespace colorStringify {
    const prototype: {
    };

}

Would be much easier for others to use this library if they could simply npm install it with a command like npm install @types/node-json-color-stringify.

Would you consider adding that?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.