Skip to content

Commit 1b8c4b8

Browse files
author
pangl
committed
chore: update readme
1 parent 94c7930 commit 1b8c4b8

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,57 @@ The following object will be passed to your method:
104104

105105
Returning `false` from a callback method will prevent the src from being affected.
106106

107+
### `ReactPureJsonView` component
108+
109+
#### Why is it needed
110+
111+
Users usually use this repository to directly connect and display `static data` (such as external JSON files, other API operation results, etc.). These static data may have (Javascript language) big number ([example](https://www.geeksforgeeks.org/how-to-deal-with-large-numbers-in-javascript/)) and floating point ([example](https://stackoverflow.com/a/55291279)) problems, and users are more interested in correctly displaying the static data and do not care about the data involving different languages ​​(Javascript) problems.
112+
113+
#### Usage
114+
115+
- JSON String Example
116+
117+
```js
118+
import { ReactPureJsonView } from '@microlink/react-json-view'
119+
120+
/**
121+
* Get `src` (json string) from the external file
122+
*
123+
* @type {String}
124+
*/
125+
const data = await fetch('data/data.json')
126+
127+
<ReactPureJsonView src={data} />
128+
```
129+
130+
- JSON Object Example (legacy mode, the same as [ReactJsonView Usage](#usage))
131+
132+
```js
133+
import { ReactPureJsonView } from '@microlink/react-json-view'
134+
135+
<ReactPureJsonView src={{
136+
string: 'this is a test string',
137+
integer: 42,
138+
array: [1, 2, 3, 'test', NaN],
139+
float: 3.14159,
140+
undefined: undefined,
141+
object: {
142+
'first-child': true,
143+
'second-child': false,
144+
'last-child': null
145+
},
146+
string_number: '1234',
147+
date: new Date(),
148+
bigNumber: new BigNumber('0.0060254656709730629123')
149+
}} />
150+
```
151+
152+
#### API
153+
154+
| Name | Type | Default | Description |
155+
|:-----------------------------|:-------------------------------------------------|:-------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
156+
| `src` | `JSON Object` or `JSON String` | None | This property contains your input JSON (object or json-string). |
157+
107158
### Theming
108159

109160
#### Builtin theme

0 commit comments

Comments
 (0)