- Install
react-pretty-json
in your project:
$ npm install react-pretty-json
- Import package and pass JSON.
import JsonView from 'react-pretty-json';
// ...
render() {
let obj = {
example: 'string',
number: 123,
boolean: true
};
return <JsonView json={obj} />;
}
- (Optional) Importing styles. You can reach it with `react-pretty-json/assets/json-view.css'.
import 'react/pretty-json/assets/json-view.css!';
Prop | Type | Default | Description |
---|---|---|---|
json* |
object | none | Generate object. |
spaces | number | 4 | Parts that will be generated js files. |
*
- Required.