simple-json-formatter

1.0.2 • Public • Published

Format JSON string with indent.

Typescript Example

let JSONFormatter = require("simple-json-formatter");

let a = {
    b: 42,
    c: "d",
    e: [
        "f",
        "g"
    ],
    h: {
        i: "j",
        k: null
    }
}

let json = JSON.stringify(a);
console.log(json);
let formattedJson = JSONFormatter.format(json, "\t");
console.log(formattedJson);

Output:

{"b":42,"c":"d","e":["f","g"],"h":{"i":"j","k":null}}
{
        "b": 42,
        "c": "d",
        "e": [
                "f",
                "g"
        ],
        "h": {
                "i": "j",
                "k": null
        }
}

Package Sidebar

Install

npm i simple-json-formatter

Weekly Downloads

38

Version

1.0.2

License

ISC

Last publish

Collaborators

  • xstoudi