pretty-object-string
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

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.

PrettyJson can format javascript string like this.

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

Package Sidebar

Install

npm i pretty-object-string

Weekly Downloads

1

Version

1.1.1

License

ISC

Unpacked Size

34 kB

Total Files

16

Last publish

Collaborators

  • superchong