Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-json-view

Package Overview
Dependencies
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-json-view

Interactive react component for displaying javascript arrays and JSON objects.

  • 1.21.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
516K
decreased by-11.07%
Maintainers
1
Weekly downloads
 
Created

What is react-json-view?

The react-json-view package is a React component for displaying and editing JSON data in a user-friendly way. It provides a variety of features to manipulate JSON data, including expanding/collapsing nodes, editing values, adding/removing nodes, and more.

What are react-json-view's main functionalities?

Display JSON Data

This feature allows you to display JSON data in a structured and readable format. The JSON data is passed to the `src` prop of the `ReactJson` component.

import React from 'react';
import ReactJson from 'react-json-view';

const App = () => {
  const jsonData = {
    name: "John Doe",
    age: 30,
    address: {
      street: "123 Main St",
      city: "Anytown"
    }
  };

  return <ReactJson src={jsonData} />;
};

export default App;

Edit JSON Data

This feature allows users to edit JSON data directly in the view. The `onEdit` prop is used to handle the edit events, providing the edited data as a parameter.

import React from 'react';
import ReactJson from 'react-json-view';

const App = () => {
  const jsonData = {
    name: "John Doe",
    age: 30,
    address: {
      street: "123 Main St",
      city: "Anytown"
    }
  };

  const handleEdit = (edit) => {
    console.log('Edited:', edit);
  };

  return <ReactJson src={jsonData} onEdit={handleEdit} />;
};

export default App;

Add/Remove JSON Nodes

This feature allows users to add or remove nodes in the JSON data. The `onAdd` and `onDelete` props are used to handle the add and delete events, respectively.

import React from 'react';
import ReactJson from 'react-json-view';

const App = () => {
  const jsonData = {
    name: "John Doe",
    age: 30,
    address: {
      street: "123 Main St",
      city: "Anytown"
    }
  };

  const handleAdd = (add) => {
    console.log('Added:', add);
  };

  const handleDelete = (del) => {
    console.log('Deleted:', del);
  };

  return <ReactJson src={jsonData} onAdd={handleAdd} onDelete={handleDelete} />;
};

export default App;

Expand/Collapse Nodes

This feature allows users to expand or collapse nodes in the JSON data. The `collapsed` prop can be set to `true` to collapse all nodes by default.

import React from 'react';
import ReactJson from 'react-json-view';

const App = () => {
  const jsonData = {
    name: "John Doe",
    age: 30,
    address: {
      street: "123 Main St",
      city: "Anytown"
    }
  };

  return <ReactJson src={jsonData} collapsed={true} />;
};

export default App;

Other packages similar to react-json-view

Keywords

FAQs

Package last updated on 09 Mar 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc