Skip to content

KitRefresh/json-string-formatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!'|}`
 */

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •