json-format
JSON format for good presentation
Last updated 9 years ago by luizstacio .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install json-format 
SYNC missed versions from official npm registry.

json-format

Build Status

Parse JavaScript Object to a JSON String indented.

Instaling

  npm install json-format

Usage

  var jsonFormat = require('./');
  var fs = require('fs');
  var obj = {
    a: 1,
    b: 2
  }

  /* using config default, indent with tabs */
  fs.writeFile('example_tabs.json', jsonFormat(obj), function(err){
    if (err) throw err;
    console.log('saved');
  });

  /* using indent with spaces */
  var config = {
    type: 'space',
    size: 2
  }

  fs.writeFile('example_spaces.json', jsonFormat(obj, config), function(err){
    if (err) throw err;
    console.log('saved');
  });
Result example_tabs.json
{
    "a": 1,
    "b": 2
}
Result example_spaces.json
{
  "a": 1,
  "b": 2
}

Default sizes

{
  tab: { size: 1 },
  space: { size: 4 }
}

Config default

{
  type: 'tab'
}

Based in this project.

Current Tags

  • 1.0.1                                ...           latest (9 years ago)

5 Versions

  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
  • 0.1.2                                ...           10 years ago
  • 0.1.1                                ...           11 years ago
  • 0.0.1                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |