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

react-json-view-lite

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-json-view-lite

JSON viewer component for React focused on performance for big source data

  • 0.9.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source
npm no dependencies size build coverage tree-shakeable types included
react-json-view-lite is a tiny component for React allowing to render JSON as a tree. It focused more on the performance for large JSON inputs rather than customization and rich features. It is written in TypeScript and has no dependencies.

Install

npm install --save react-json-view-lite

Usage

import * as React from 'react';

import { JsonView, darkStyles, defaultStyles } from 'react-json-view-lite';
import 'react-json-view-lite/dist/index.css';

const json = {
  a: 1,
  b: 'example',
};

const App = () => {
  return (
    <React.Fragment>
      <JsonView
        data={json}
        shouldInitiallyExpand={(level) => true}
        style={defaultStyles}
      />
      <JsonView data={json} shouldInitiallyExpand={(level) => true} style={darkStyles} />
    </React.Fragment>
  );
};

export default App;

Props

NameTypeDefault ValueDescription
dataObject | Array<any>Data which should be rendered
styleStylePropsdefaultStylesCSS classes for rendering. Library provides two build-in implementations: darkStyles, defaultStyles
shouldInitiallyExpand(level: number, value: any, field?: string) => booleanundefinedOptional. Function which will be initially called for each Object and Array of the data in order to calculate should if this node be expanded

StyleProps

NameTypeDescription
containerstringCSS class name for rendering parent block
basicChildStylestringCSS class name for property block containing property name and value
expanderstringCSS class name for rendering button expanding/collapsing Object and Array nodes
labelstringCSS class name for rendering property names
nullValuestringCSS class name for rendering null values
undefinedValuestringCSS class name for rendering undefined values
numberValuestringCSS class name for rendering numeric values
stringValuestringCSS class name for rendering string values
booleanValuestringCSS class name for rendering boolean values
otherValuestringCSS class name for rendering all other values except Object, Arrray, null, undefined, numeric, boolean and string
punctuationstringCSS class name for rendering ,, [, ], {, }

Comparison with other libraries

Here is the size benchmark (using bundlephobia.com) against similar React libraries (found by https://www.npmjs.com/search?q=react%20json&ranking=popularity):

NameBundle sizeBundle size (gzip)Dependencies
react-json-view-lite
react-json-pretty
react-json-inspector
react-json-tree
react-json-view
react-json-tree-viewer

License

MIT © AnyRoad

FAQs

Package last updated on 25 Jul 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