json-string-formatter
A json string formatter with zero dependency.
Last updated 2 years ago by yeze322 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install json-string-formatter 
SYNC missed versions from official npm registry.

JSON String Formatter

A lightweight JSON string formatter which can prettify your JSON string without parsing it to object.

Install

npm install --save json-string-formatter

or

yarn add json-string-formatter

Usage

  1. Import
const { format } = require('json-string-formatter';

// or

const jsonFormatter = require('json-string-formatter');

jsonFormatter.format(...)

  1. Basic usage

let input = "{'text': 'hello world!'}";
let output = format(input);

/**
 * output = `{
 *  'text': 'hello world!'
 * }`
 * /
  1. Customized indent and linebreak

let input = "{'text': 'hello world!'}";
let output = format(input, /* indent */ '--', /* linebreak */ '|');

/**
 * output = `{|--'text': 'hello world!'|}`
 */

Current Tags

  • 1.0.1                                ...           latest (2 years ago)

2 Versions

  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 9
Last Day 1
Last Week 11
Last Month 218
Dependencies (0)
None
Dev Dependencies (2)

Copyright 2014 - 2016 © taobao.org |