console.json

console.json

Adds console.json method that stringifies passed in objects and logs them.

This is a sweet little util function by Gleb Bahmutov that makes a life bit easier while debugging huge json data in the console. P.S: There is console.dir but console.json is kina appleaing expect for the color highlighting part of it.

Install it: npm install --save console.json

Sample usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Just require it once and you shall have `console.json` method for convenience.

require('console.json');


var data = {
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Product",
    "description": "A product from Acme's catalog",
    "type": "object",
    "properties": {
        "id": {
            "description": "The unique identifier for a product",
            "type": "integer"
        },
        "name": {
            "description": "Name of the product",
            "type": "string"
        }
    },
    "required": ["id", "name"]
};

console.json(data);

GIF FTW!:

console.json

Suggest a module

Comments