Socket
Socket
Sign inDemoInstall

json-format

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    json-format

JSON format for good presentation


Version published
Maintainers
1
Install size
5.76 kB
Created

Readme

Source

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.

Keywords

FAQs

Last updated on 06 Apr 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc