format-json-pretty

format object to pretty json

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
format-json-pretty
221.0.17 years ago7 years agoMinified + gzip package size for format-json-pretty in KB

Readme

format-json-pretty
format object to pretty json
update: Support for defining the number of indent spaces. The default is 2

INSTALL

npm install format-json-pretty

TEST

npm run test

DEMO

var formatJson = require('format-json-pretty');

var user = {
  id: 1,
  name: 'fengliner',
  color: {
    id: 1,
    name: 'fengliner'
  },
  font: [{id: 1, name: 'fengliner'}]
};

console.log(formatJson(user));

/**
{
  "id": 1,
  "name": "fengliner",
  "color": {
    "id": 1,
    "name": "fengliner"
  },
  "font": [{
    "id": 1,
    "name": "fengliner"
  }]
}
*/

 console.log(foramtJson(user, 4));

 /**
 {
    "id": 1,
    "name": "fengliner",
    "color": {
        "id": 1,
        "name": "fengliner"
    },
    "font": [{
        "id": 1,
        "name": "fengliner"
    }]
}
*/