Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
react-json-formatter
Advanced tools
React component to formate JSON data
npm i react-json-formatter
yarn add react-json-formatter
pnpm i react-json-formatter
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
The string of Json to formate.
The number of spaces it should use per tab. The default is 2.
Use the Object jsonStyle
to control the style of formatted JSON.
style | part |
---|---|
propertyStyle | The properties of Object. |
colonStyle | The colons of Object. |
style | The whole parts of the formatted JSON. |
tabSpaceStyle | The space of the tabs at Object or Array. |
numberStyle | The numbers in JSON. |
stringStyle | The strings in JSON. |
booleanStyle | Both boolean values in JSON. |
trueStyle | The boolean values of true in JSON. |
falseStyle | The boolean values of false in JSON. |
nullStyle | The null values in JSON |
commaStyle | The commas used in Array and Object |
braceStyle | The braces of Object. |
bracketStyle | The brackets of Array. |
Use the Object jsonClassName
to add the className to formatted JSON.
style | part |
---|---|
propertyClassName | The properties of Object. |
colonClassName | The colons of Object. |
className | The whole parts of the formatted JSON. |
tabSpaceClassName | The space of the tabs at Object or Array. |
numberClassName | The numbers in JSON. |
stringClassName | The strings in JSON. |
booleanClassName | Both boolean values in JSON. |
trueClassName | The boolean values of true in JSON. |
falseClassName | The boolean values of false in JSON. |
nullClassName | The null values in JSON |
commaClassName | The commas used in Array and Object |
braceClassName | The braces of Object. |
bracketClassName | The brackets of Array. |
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
MIT © ronny1020
FAQs
Formatting json data to JSX of React
The npm package react-json-formatter receives a total of 3,562 weekly downloads. As such, react-json-formatter popularity was classified as popular.
We found that react-json-formatter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.