1.1.1 • Published 4 years ago

pretty-object-string v1.1.1

Weekly downloads
17
License
ISC
Repository
github
Last release
4 years ago

PrettyJson

NPM version Test coverage npm download

Usage

There is a vscode extension Pretty js/json use this package to format pretty json or javascript object string.

Getting Started

install

With yarn

yarn add pretty-object-string

or using npm

npm install pretty-object-string

PrettyJson can format javascript string like this.

let a = `{
  code: 200,
  msg: "success",
  datas:[{
    name:'小王',
    age:2
  },{
    'name':"校长",
    age:10
  }]
}`

const prettyJson = require('pretty-object-string')

const out = prettyJson(a)
console.log(out)
/**
 * {
 *	"code": 200,
 *	"msg": "success",
 *	"datas": [
 *		{
 *			"name": "小王",
 *			"age": 2
 *		},
 *		{
 *			"name": "校长",
 *			"age": 10
 *		}
 *	]
 * }
 */

options

const prettyJson = require('pretty-object-string')

const a = { name: 1 }
const out = prettyJson(a, { indent: ' '.repeat(2) })
console.log(out)
{
  "name": 1
}
2.0.0-beta.3

4 years ago

2.0.0-beta.2

4 years ago

2.0.0-beta.1

4 years ago

2.0.0-beta.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago