New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-json-component

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-json-component

React component that allows you to render JSON documents or serializable JavaScript objects written with TypeScript.

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
415
-0.72%
Maintainers
1
Weekly downloads
 
Created
Source

Description

React component that allows you to render JSON documents or serializable JavaScript objects written with TypeScript.

Read a blog post about it below: Recursive rendering in React: Building a universal JSON renderer

Usage

  • run npm install react-json-component in your React project
  • import ReactJsonRenderer from 'react-json-component' in your app

NOTE: Currently only supports ES6 modules

Example

import * as React from 'react';
import RecursiveComponent from 'react-json-component';

const testJson = {
  "_id": "5bc32f3f5fbd8ad01f8265fd",
  "objectWithNulls": {
     "firstNullValue": null,
     "secondNullValue": null     
  },
  "longitude": 65.090852,
  "tags": [
    "ea",
    "officia",
  ],
  "friends": [
    {
      "id": 0,
      "name": "Genevieve Cooke",
      "ownFriends": {
         "1": "Rebbeca",
         "2": "Julia",
         "3": "Chopper only"
      },
    },
    {
      "id": 1,
      "name": "Eaton Buck"
    }
  ]
};

class App extends React.Component {
  public render() {
    return (
      <div className="App">
          <RecursiveComponent
            property={testJson}
            propertyName="Root Property"
            excludeBottomBorder={false}
            rootProperty={true}/>
      </div>
    );
  }
}

Props

<RecursiveProperty
    property={json} // your JSON document
    propertyName="root" // root dropdown menu label
    excludeBottomBorder={true} // to include or exclude bottom border on the last entry in the list, default: false
    emptyPropertyLabel="Property is empty" // text to display for null or undefined values
    rootProperty={true} // to signify that this is the root of the document, from a user perspective always needs to be true
    propertyNameProcessor={(name) => name + ": "} // function that processes property names, default: processes from camelCase to normal text
/>

Development

  • git clone or download this repository
  • run npm install in repository
  • run npm start to start the development server

Keywords

react

FAQs

Package last updated on 02 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts