githubEdit

react-json-tree

React JSON Viewer Component, Extracted from redux-devtoolsarrow-up-right. Supports iterablearrow-up-right objects, such as Immutable.jsarrow-up-right.

Usage

Result:

Check out examplesarrow-up-right directory for more details.

Theming

This component now uses react-base16-stylingarrow-up-right module, which allows to customize component via theme property, which can be the following:

Every theme has a light version, which is enabled with invertTheme prop.

Result (Monokai theme, dark background):

Advanced Customization

Customize Labels for Arrays, Objects, and Iterables

You can pass getItemString to customize the way arrays, objects, and iterable nodes are displayed (optional).

By default, it'll be:

But if you pass the following:

Then the preview of child elements now look like this:

Customize Rendering

You can pass the following properties to customize rendered labels and values:

In this example the label and value will be rendered with <strong> and <em> wrappers respectively.

For labelRenderer, you can provide a full path - see this PRarrow-up-right.

More Options

  • shouldExpandNode: function(keyName, data, level) - determines if node should be expanded (root is expanded by default)

  • hideRoot: Boolean - if true, the root node is hidden.

  • sortObjectKeys: Boolean | function(a, b) - sorts object keys with compare function (optional). Isn't applied to iterable maps like Immutable.Map.

Credits

Similar Libraries

License

MIT

Last updated