Interactive Json Viewer, but not only a json viewer
npm install @textea/json-viewer@textea/json-viewer is a React component that can be used to view and display any kind of data, not just JSON.
Object, Array, primitive types, and even Map and Set.
@textea/json-viewer is using Material-UI as the base component library, so you need to install it and its peer dependencies first.
sh
npm install @textea/json-viewer @mui/material @emotion/react @emotion/styled
`
$3
`html
`
Usage
Here is a basic example:
`jsx
import { JsonViewer } from '@textea/json-viewer'
const object = {
/ my json object /
}
const Component = () =>
`
$3
You can define custom data types to handle data that is not supported out of the box. Here is an example of how to display an image:
`jsx
import { JsonViewer, defineDataType } from '@textea/json-viewer'
const object = {
image: 'https://i.imgur.com/1bX5QH6.jpg'
// ... other values
}
// Let's define a data type for image
const imageDataType = defineDataType({
is: (value) => typeof value === 'string' && value.startsWith('https://i.imgur.com'),
Component: (props) =>
})
const Component = () =>
``