Giter Site home page Giter Site logo

react-json-inspector's Introduction

React JSON Inspector Component

Component screenshot

React-based JSON inspector that features tree expansion and fast search.

Live demo

Installation

npm install react-json-inspector

Usage

var Inspector = require('react-json-inspector');
var data = { /* ... */ };

React.render(
    <Inspector data={ data } />,
    document.getElementById('inspector')
);

Make sure to include json-inspector.css in your stylesheet. Feel free to override or amend default styles, for instance, when using a dark background.

Run the example

cd /path/to/project
npm install
npm run watch

Then, visit http://localhost/path/to/project/example

Properties

props.data

The only required propery, JSON object or array to inspect.

props.className

The class name to be added to the root component element.

props.search

Search bar component that accepts onChange and data properties. Defaults to built-in search bar. Pass false to disable search.

props.interactiveLabel

Pass component factory that would receive the following properties:

  • value, either stringified property value or key value that is being interacted with,
  • originalValue, either the original property value or key value,
  • isKey, boolean flag to differentiate between interacting with keys or properties,
  • keypath, keypath of the node being interacted with, will be the same for keys and properties

Can be used to create custom input fields for JSON property names and primitive values, see #3 for more information.

props.onClick

Callback to be run whenever any key-value pair is clicked. Receives an object with key, value and path properties.

props.validateQuery

Function to check whether the entered search term is sufficient to query data. Defaults to (query) => query.length >= 2.

props.isExpanded

Optional predicate that can determine whether the leaf node should be expanded on initial render. Receives two arguments: keypath and value. Defaults to (keypath, query) => false.

props.filterOptions

Optional parameters for filterer (search). Must be an object.

  • ignoreCase, Set to true to enable case insensitivity in search. Defaults to false.

react-json-inspector's People

Contributors

lapple avatar rutsky avatar jonasfj avatar joona avatar

Stargazers

Michael Anthony avatar

Watchers

Michael Anthony avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.