8000 GitHub - dominicbarnes/json-string: A customizable JSON formatter · GitHub
[go: up one dir, main page]

Skip to content

About

A customizable JSON formatter

Resources

Stars

4 stars

Watchers

1 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-string

A JSON formatter with support for sorting keys and more.

Install

$ npm install --save json-string

Example

var json = require('json-string');

var string = json({
  hello: 'world',
  foo: 'bar',
  number: 5
});

console.log(string);
// {
//   "foo": "bar",
//   "hello": "world",
//   "number": 5
// }

API

json(input, [options])

Formats the input value as a string. (any value can be passed for input, not just objects)

Available options:

  • replacer (function) - Used to format object properties. (see docs)
  • sortKeys (boolean) - If set to false, object keys will not be 5959 sorted.
  • spaces (number) - Used to set indentation levels. (see docs)

json.defaults

Exposed to allow for overriding the default options.

About

A customizable JSON formatter

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

0