New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-json-formatter

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-json-formatter

Formatting json data to JSX of React

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.7K
decreased by-13.67%
Maintainers
1
Weekly downloads
 
Created
Source

react-json-formatter

React component to formate json data

NPM JavaScript Style Guide

Install

npm install --save react-json-formatter

Usage

App.js

import React from 'react'

import { JsonFormatter } from 'react-json-formatter'
import './index.css'

const App = () => {
  const sample = `{
   "string":"ABCDE",
   "number":1,
   "null":null,
   "boolean":true,
   "object":{
      "string":"ABCDE",
      "number":1,
      "null":null,
      "boolean":true
   },
   "array":[
      1,
      2,
      3,
      4,
      {
      "string":"ABCDE",
      "number":1,
      "null":null,
      "boolean":true,
         "array":[
      1,
      2,
      3,
      4,
      {
      "string":"ABCDE",
      "number":1,
      "null":null,
      "boolean":true
   }
   ]
   }
   ]
}
`

  return <JsonFormatter json={sample} tabWith='2' />
}

export default App
}

index.css

.react-json-property {
  color: red;
}

Demo

Demo

Attributes

json : string(Json)

The string of Json to formate.

tabWith : number

Number of spaces it should use per tab. The default is 4.

style

There is className for each part of the formatted Json. Thus, the style can be changed by className.

classNamepart
react-jsonThe whole parts of the formatted Json.
react-json-tabSpaceThe space of the tabs at Object or Array.
react-json-numberThe numbers in Json.
react-json-stringThe strings in Json.
react-json-trueThe boolean values of true in Json.
react-json-falseThe boolean values of false in Json.
react-json-braceThe braces of Object.
react-json-propertyThe properties of Object.
react-json-colonThe colons of Object.
react-json-bracketThe brackets of Array.
react-json-nullThe null values in Json

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT © ronny1020

Keywords

FAQs

Package last updated on 04 Jun 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

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