jsoncolor
Configurable and simple JSON colorizer
I had various issues with other JSON-color libraries (they choke on certain characters, etc.) I wanted something lightweight, easily configurable and simple that works, so I made this.
It handles JSON, and JSON-serializable objects.
installation
npm i jsoncolor
usage
const jsoncolor = console
You can also change the colors. Just set the right fields in colors
to functions that colorize your text. These are the defaults, but you can use anything:
jsoncolorcolors = number: chalk key: chalk string: chalk boolean: chalk null: chalk
If you wanted to use more basic colors:
jsoncolorcolors = number: chalkred key: chalkmagenta string: chalkgreen boolean: chalkblue null: chalkcyan
If you wanted to output HTML:
jsoncolorcolors = `<span class="number"></span>` `<span class="key"></span>` `<span class="string"></span>` `<span class="boolean"></span>` `<span class="null"></span>`
if you don't care about colors or JSON at all:
jsoncolorcolors = `NUMBER()` `KEY()` `STRING()` `BOOLEAN()` `NULL`