1.0.0 • Published 4 years ago

react-json-beautify v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

react-json-beautify

npm package GitHub license

A react component for rendering JSON data as a tree structure.

Based on vue-json-pretty.

Install

yarn add react-json-beautify

Usage

import ReactJsonBeautify from 'react-json-beautify';
import 'react-json-beautify/styles.css';

ReactDOM.render(<ReactJsonBeautify {...props} />, mountNode);

Example

<ReactJsonBeautify
  data={data}
  deep={options.deep}
  showDoubleQuotes={options.showDoubleQuotes}
  showLength={options.showLength}
  showLine={options.showLine}
  highlightMouseoverNode={options.highlightMouseoverNode}
  collapsedOnClickBrackets={options.collapsedOnClickBrackets}
  onClick={handleClick}
/>

Props

  • If you are using only the normal features (JSON pretty), just focus on the base properties.
  • If you are using higher features (Get data), you can use base and higher attributes.
AttributeLevelDescriptionTypeDefault
datanormaljson dataJSON object-
deepnormaldata depth, data larger than this depth will not be expandednumberInfinity
showLengthnormalwhether to show the length when closedbooleanfalse
showLinenormalwhether to show the linebooleantrue
showDoubleQuotesnormalwhether to show doublequotes on keybooleantrue
highlightMouseoverNodenormalhighlight current node when mouseoverbooleanfalse
collapsedOnClickBracketsnormalcollapse controlbooleantrue
v-modelhigherdefines value when the tree can be selectedstringstring[]-, []
pathhigherroot data pathstringroot
pathCheckedhigherdefines the selected data patharray[]
pathSelectablehigherdefines whether a data path supports selectionFunction(itemPath, itemData)-
selectableTypehigherdefines the selected type, this feature is not supported by defaultenum: multiple, single-
showSelectControllerhigherwhether to show the select controller at leftbooleanfalse
selectOnClickNodehigherwhether to change selected value when click nodebooleantrue
highlightSelectedNodehigherhighlight current node when selectedbooleantrue
onClick-triggered when a data item is clickedFunction(path, data)-
onChange-triggered when the selected value changed (only the selectableType not null)Function(newVal, oldVal)-