Skip to content

Latest commit

 

History

History
73 lines (50 loc) · 2.82 KB

README.md

File metadata and controls

73 lines (50 loc) · 2.82 KB

@crashmax/json-format-highlight

NPM version NPM downloads GitHub Workflow

✨ Format json and highlight it as well.

Demo

You can play with @crashmax/json-format-highlight on foorks.github.io/json-format-highlight or codesandbox.io

Edit @crashmax/json-format-highlight

Features

Note:

  • May not be suitable for handling huge (such as 10MB) JSON.

Installation

# with npm:
npm install @crashmax/json-format-highlight

# or yarn:
yarn add @crashmax/json-format-highlight

CDN:

Usage

import formatHighlight from '@crashmax/json-format-highlight'

const json = {
  ok: true,
  status: 200,
  message: 'hello world'
}

formatHighlight(json, /** options */)

Options

Key Type Default Description
keyColor string #9cdcfe Key color
numberColor string #569cd6 Color of the value of the number type
stringColor string #ce9178 Color of the value of the string type
trueColor string #569cd6 Color of the value of the boolean type and equals to true
falseColor string #569cd6 Color of the value of the string type and equals to false
nullColor string #569cd6 Color of the value of the null type
bracketsColor string #d4d4d4 Color of the brackets symbol
backgroundColor string #1e1e1e Color of the background

If you don't pass in anything this argument, default colors would be used. If you do pass in an object for this argument, the colors you specified would override the default color scheme.

License

MIT © luyilin

minemine.cc · GitHub @luyilin · Twitter @luyilin12