Socket
Book a DemoInstallSign in
Socket

clear-json

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clear-json

view json string in a pretty format

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

clear-json

show json with a pretty format

Install

$ npm install clear-json --save

Usage

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import ClearJson from 'clear-json';


const json = JSON.stringify({ 
  string: '张春秋',
  number: 90,
  array: [
    { id: 24, name: '管理员' },
    { id: 45, name: '办事员' }
  ],
  object: {
    key0: 'value0'
  },
  null: null
  boolean: false
});

ReactDOM.render(<ClearJson json={json} />, document.getElementById('root'));

Theme

ReactDOM.render(<ClearJson json={json} theme="dark" />, document.getElementById('root'));

customize style

.clear-json-theme-dark {
  background-color: #1e1e1e;
  color: #ddd;
  .node-key {
    color: #9cdcfe;
  }
  .node-value {
    color: #ce9178;
  }
  .node-bracket {
    color: orchid;
  }
}

operations

ReactDOM.render(<ClearJson json={json} operations={[
  <span onClick={(e, node) => {
    e && e.stopPropagation();
    console.log(node);
  }}>自定义</span>,
  'copy'
]} theme="dark" />, document.getElementById('root'));

Keywords

json

FAQs

Package last updated on 15 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts