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.2.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 i react-json-formatter

Usage

App.js

import React from 'react'

import { JsonFormatter } from 'react-json-formatter'

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
   }
   ]
   }
   ]
}
`

  const JsonStyle = {
    propertyStyle: { color: 'red' },
    stringStyle: { color: 'green' },
    numberStyle: { color: 'darkorange' }
  }

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

export default App

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

Use the Object JsonStyle to control the style of formatted Json.

  • from the 0.2.0 version, NOT support for className.
stylepart
propertyStyleThe properties of Object.
colonStyleThe colons of Object.
styleThe whole parts of the formatted Json.
tabSpaceStyleThe space of the tabs at Object or Array.
numberStyleThe numbers in Json.
stringStyleThe strings in Json.
trueStyleThe boolean values of true in Json.
falseStyleThe boolean values of false in Json.
nullStyleThe null values in Json
commaStyleThe commas used in Array and Object
braceStyleThe braces of Object.
bracketStyleThe brackets of Array.

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 22 Aug 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