GitHub
github.com › alexkuz › react-json-tree
GitHub - alexkuz/react-json-tree: React JSON Viewer Component, Extracted from redux-devtools
import JSONTree from 'react-json-tree' ... // Inside a React component: const json = { array: [1, 2, 3], bool: true, object: { foo: 'bar' }, immutable: Map({ key: 'value' }) } <JSONTree data={json} /> Check out examples directory for ...
Starred by 997 users
Forked by 115 users
Languages JavaScript 100.0% | JavaScript 100.0%
GitHub
github.com › Dean177 › react-native-json-tree
GitHub - Dean177/react-native-json-tree: React Native JSON Viewer Component, based on react-json-tree
import JSONTree from ... // Inside a React component: const json = { array: [1, 2, 3], bool: true, object: { foo: 'bar' } immutable: Map({ key: 'value' }) } <JSONTree data={json} /> Check out the Example ...
Starred by 122 users
Forked by 33 users
Languages JavaScript 100.0% | JavaScript 100.0%
GitHub
github.com › STRML › react-json-tree-editable
GitHub - STRML/react-json-tree-editable: React JSON Viewer Component, Extracted from redux-devtools
import JSONTree from 'react-json-tree' ... // Inside a React component: const json = { array: [1, 2, 3], bool: true, object: { foo: 'bar' }, immutable: Map({ key: 'value' }) } <JSONTree data={json} /> Check out examples directory for ...
Forked by 2 users
Languages JavaScript 100.0% | JavaScript 100.0%
GitHub
github.com › oxyno-zeta › react-editable-json-tree
GitHub - oxyno-zeta/react-editable-json-tree: React Editable Json Tree
// Import import { JsonTree, ADD_DELTA_TYPE, REMOVE_DELTA_TYPE, UPDATE_DELTA_TYPE, DATA_TYPES, INPUT_USAGE_TYPES, } from 'react-editable-json-tree' // Data const data = { error: new Error('error'), text: 'text', int: 100, boolean: true, null: null, object: { text: 'text', int: 100, boolean: true, }, array: [ 1, { string: 'test', }, ], } // Component <JsonTree data={data} />
Starred by 109 users
Forked by 20 users
Languages JavaScript 88.8% | TypeScript 11.0% | HTML 0.2% | JavaScript 88.8% | TypeScript 11.0% | HTML 0.2%
GitHub
github.com › reduxjs › redux-devtools › tree › main › packages › react-json-tree
redux-devtools/packages/react-json-tree at main · reduxjs/redux-devtools
import { JSONTree } from ... Inside a React component: const json = { array: [1, 2, 3], bool: true, object: { foo: 'bar', }, immutable: Map({ key: 'value' }), }; <JSONTree data={json} />; Check out examples directory ...
Author reduxjs
GitHub
github.com › grafana › react-json-tree
GitHub - grafana/react-json-tree: Fork of https://github.com/reduxjs/redux-devtools/tree/main/packages/react-json-tree
import { JSONTree } from ... Inside a React component: const json = { array: [1, 2, 3], bool: true, object: { foo: "bar", }, immutable: Map({ key: "value" }), }; <JSONTree data={json} />;...
Author grafana
GitHub
github.com › STRML › react-json-tree-editable › blob › master › README.md
react-json-tree-editable/README.md at master · STRML/react-json-tree-editable
import JSONTree from 'react-json-tree' ... a React component: const json = { array: [1, 2, 3], bool: true, object: { foo: 'bar' }, immutable: Map({ key: 'value' }) } · <JSONTree data={json} /> ``` · #### Result: ...
Author STRML
GitHub
github.com › mac-s-g › react-json-view
GitHub - mac-s-g/react-json-view: JSON viewer for react · GitHub
Starred by 3.7K users
Forked by 500 users
Languages JavaScript 96.4% | Shell 2.9%
GitHub
github.com › bvaughn › react-json-tree
GitHub - bvaughn/react-json-tree: React JSON Viewer Component, Extracted from redux-devtools
import JSONTree from 'react-json-tree' ... // Inside a React component: const json = { array: [1, 2, 3], bool: true, object: { foo: 'bar' } immutable: Map({ key: 'value' }) } <JSONTree data={ json } /> Check out examples directory for ...
Author bvaughn
GitHub
github.com › gaearon › react-json-tree
GitHub - gaearon/react-json-tree: React JSON Viewer Component, Extracted from redux-devtools
import JSONTree from 'react-json-tree' ... // Inside a React component: const json = { array: [1, 2, 3], bool: true, object: { foo: 'bar' } immutable: Map({ key: 'value' }) } <JSONTree data={ json } /> Check out examples directory for ...
Author gaearon
GitHub
github.com › AnyRoad › react-json-view-lite
GitHub - AnyRoad/react-json-view-lite: Lightweight Json view component for React
react-json-view-lite is a tiny component for React allowing to render JSON as a tree. It focused on the balance between performance for large JSON inputs and functionality. It might not have all the rich features (suce as customization, copy, json editinng) but still provides more than just rendering json with highlighting - e.g.
Starred by 235 users
Forked by 25 users
Languages TypeScript 95.9% | CSS 4.1% | TypeScript 95.9% | CSS 4.1%
GitHub
github.com › krispo › redux-json-tree
GitHub - krispo/redux-json-tree: Editable JSON tree React component for deeply nested data.
React/Redux editable JSON tree component for deeply nested data, with a single store. It simulates a simple two-way data-binding mechanism. It works on top of simplifr. In two words, it transforms JSON into a flat structure that describe each ...
Starred by 21 users
Forked by 2 users
Languages JavaScript 83.4% | CSS 11.2% | HTML 5.4% | JavaScript 83.4% | CSS 11.2% | HTML 5.4%
UNPKG
unpkg.com › browse › react-json-tree@0.15.0 › README.md
react-json-tree/README.md
By default, it'll be: ```jsx <JSONTree getItemString={(type, data, itemType, itemString, keyPath) => <span>{itemType} {itemString}</span>} ``` But if you pass the following: ```jsx const getItemString = (type, data, itemType, itemString, keyPath) => (<span> // {type}</span>); ``` Then the preview ...
Top answer 1 of 3
9
Recursion is fun!
const data = [{
title: "Node 1",
childNodes: [
{ title: "Childnode 1.1" },
{
title: "Childnode 1.2",
childNodes: [
{
title: "Childnode 1.2.1",
childNodes: [
{ title: "Childnode 1.2.1.1" }
]
}, { title: "Childnode 1.2.2" }
]
}
]
}];
const App = () => (
<form>
<Tree data={data} />
</form>
);
const Tree = ({data}) => (
<ul>
{data && data.map(item => (
<li>
{item.title}
{item.childNodes && <Tree data={item.childNodes} />}
</li>
))}
</ul>
);
Demo: https://codesandbox.io/s/01kl2xmo40
2 of 3
1
This example below can work on all json objects i have tested it on checkout my github repo: https://github.com/nickjohngray/blockout/blob/master/src/Tree/Tree.tsx the html generated is the same as https://www.w3schools.com/howto/howto_js_treeview.asp
class Tree extends React.Component {
processObject = (object) =>
Object.keys(object).map((key, reactKey) => {
return (
<li key={reactKey + key}>
{this.buildNode(key)}
<ul className="nested">
{this.isPrimative(object[key]) ? this.buildLeaf(object[key]) :
this.isArray(object[key]) ? this.loopArray(object[key]) : this.processObject(object[key])}
</ul>
</li>
)
})
loopArray = (array) =>
array.map((value, key) =>
<div key={key + value}>
{this.isPrimative(value) ? this.buildLeaf(value) :
this.isArray(value) ? this.loopArray(value) : this.processObject(value)}
</div>
)
isArray = (value) =>
Array.isArray(value)
isPrimative = (value) => {
return typeof (value) === 'string'
|| typeof (value) === 'number'
|| typeof (value) === 'boolean'
}
buildNode = (key: string) =>
<span className="node"
onClick={
(e) => {
this.toggle(e)
}}>
{key}
</span>
buildLeaf = (value: string) =>
<li className="leaf"
onClick={
(e) => {
}}>
{value}
</li>
toggle = (event) => {
event.target.parentElement.querySelector(".nested").classList.toggle("active");
event.target.classList.toggle("node-down");
}
render = () => <>
<ul id="myUL">
{this.processObject(json)}
</ul>
</>
}
export default Tree;
this is the css for it, copied from wc3 schools
/* Remove default bullets */
ul, #myUL {
list-style-type: none;
}
body {
background: red;
}
/* Remove margins and padding from the parent ul */
#myUL {
margin: 0;
padding: 0;
}
/* Style the caret/arrow */
.caret {
cursor: pointer;
user-select: none; /* Prevent text selection */
background: red;
}
/* Create the caret/arrow with a unicode, and style it */
.caret::before {
content: "\25B6";
color: black;
display: inline-block;
margin-right: 6px;
}
/* Rotate the caret/arrow icon when clicked on (using JavaScript) */
.caret-down::before {
transform: rotate(90deg);
}
/* Hide the nested list */
.nested {
display: none;
}
/* Show the nested list when the user clicks on the caret/arrow (with JavaScript) */
.active {
display: block;
}
GitHub
github.com › rsolomon › react-json-tree
GitHub - rsolomon/react-json-tree: React JSON Viewer Component, Extracted from redux-devtools
import JSONTree from 'react-json-tree' ... // Inside a React component: const json = { array: [1, 2, 3], bool: true, object: { foo: 'bar' }, immutable: Map({ key: 'value' }) } <JSONTree data={json} /> Check out examples directory for ...
Author rsolomon
GitHub
github.com › measuredco › react-from-json
GitHub - chrisvxd/react-from-json: Declare your React component ...
Declare your React component tree in JSON · react-from-json lets you render React · <Foo> <Bar baz="Hello, world" /> </Foo> from JSON · { "type": "Foo", "props": { "children": { "type": "Bar", "props": { "baz": "Hello, world" } } } } It also ...
Starred by 144 users
Forked by 10 users
Languages TypeScript 99.0% | JavaScript 1.0% | TypeScript 99.0% | JavaScript 1.0%
GitHub
github.com › expreva › react-json-tree
GitHub - expreva/react-json-tree: React JSON viewer component extracted from redux-devtools
import { JSONTree } from ... Inside a React component: const json = { array: [1, 2, 3], bool: true, object: { foo: 'bar', }, immutable: Map({ key: 'value' }), }; <JSONTree data={json} />; Check out examples directory ...
Author expreva
CodeSandbox
codesandbox.io › examples › package › react-json-tree
react-json-tree examples - CodeSandbox
landingpage-react-template · Find more examples or templates · AboutReact JSON Viewer Component, Extracted from redux-devtools897,042Weekly Downloads · Latest version0.20.0 · LicenseMIT · External Links · github.com/reduxjs/redux-devtools/tree/master/packages/react-json-tree ·
GitHub
github.com › reduxjs › redux-devtools › blob › main › packages › react-json-tree › src › createStylingFromTheme.ts
redux-devtools/packages/react-json-tree/src/createStylingFromTheme.ts at main · reduxjs/redux-devtools
DevTools for Redux with hot reloading, action replay, and customizable UI - redux-devtools/packages/react-json-tree/src/createStylingFromTheme.ts at main · reduxjs/redux-devtools
Author reduxjs
GitHub
github.com › okozolin › json-tree-view-material-ui
GitHub - okozolin/json-tree-view-material-ui: Show JSON api in a recursive tree view. Styles with React Material-ui
Shows it in a tree view where nodes can be expanded and collapsed. The component handles any valid JSON, without any expectations regarding its structure. TThe page that contains the component controls the URL from which the data is obtained.
Author okozolin