Installations
npm install @sishuguojixuefu/react-native-json-tree
Releases
Unable to fetch releases
Developer
Dean177
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
12.16.2
NPM Version
6.14.6
Statistics
117 Stars
62 Commits
30 Forks
5 Watching
15 Branches
11 Contributors
Updated on 17 Oct 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
2,271
Last day
-66.7%
1
Compared to previous day
Last week
90%
19
Compared to previous week
Last month
51.6%
47
Compared to previous month
Last year
-8.1%
466
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
react-native-json-tree
React Native JSON Viewer Component, based on react-json-tree. Supports iterable objects, such as Immutable.js.
Usage
1import JSONTree from 'react-native-json-tree' 2// If you're using Immutable.js: `npm i --save immutable` 3import { Map } from 'immutable' 4 5// Inside a React component: 6const json = { 7 array: [1, 2, 3], 8 bool: true, 9 object: { 10 foo: 'bar' 11 } 12 immutable: Map({ key: 'value' }) 13} 14 15<JSONTree data={json} />
Result:
Check out the Example directory.
Theming
This component now uses react-base16-styling module, which allows to customize component via theme
property, which can be the following:
- base16 theme data. The example theme data can be found here.
- object that contains style objects, strings (that treated as classnames) or functions. A function is used to extend its first argument
{ style, className }
and should return an object with the same structure. Other arguments depend on particular context (and should be described here). See createStylingFromTheme.js for the list of styling object keys. Also, this object can extendbase16
theme viaextend
property.
Every theme has a light version, which is enabled with invertTheme
prop.
1const theme = { 2 scheme: 'monokai', 3 author: 'wimer hazenberg (http://www.monokai.nl)', 4 base00: '#272822', 5 base01: '#383830', 6 base02: '#49483e', 7 base03: '#75715e', 8 base04: '#a59f85', 9 base05: '#f8f8f2', 10 base06: '#f5f4f1', 11 base07: '#f9f8f5', 12 base08: '#f92672', 13 base09: '#fd971f', 14 base0A: '#f4bf75', 15 base0B: '#a6e22e', 16 base0C: '#a1efe4', 17 base0D: '#66d9ef', 18 base0E: '#ae81ff', 19 base0F: '#cc6633' 20}; 21 22<JSONTree data={data} theme={theme} invertTheme={false} /> 23
Result (Monokai theme, dark background):
Advanced Customization
1<JSONTree data={data} theme={{ 2 extend: theme, 3 // underline keys for literal values 4 valueLabel: { 5 textDecoration: 'underline' 6 }, 7 // switch key for objects to uppercase when object is expanded. 8 // `nestedNodeLabel` receives additional arguments `expanded` and `keyPath` 9 nestedNodeLabel: ({ style }, nodeType, expanded) => ({ 10 style: { 11 ...style, 12 textTransform: expanded ? 'uppercase' : style.textTransform 13 } 14 }) 15}} />
Customize Labels for Arrays, Objects, and Iterables
You can pass getItemString
to customize the way arrays, objects, and iterable nodes are displayed (optional).
By default, it'll be:
1<JSONTree getItemString={(type, data, itemType, itemString) => 2 <Text>{itemType} {itemString}</Text>} 3/>
But if you pass the following:
1const getItemString = (type, data, itemType, itemString) => 2 <Text>{type}</Text>;
Then the preview of child elements now look like this:
Customize Rendering
You can pass the following properties to customize rendered labels and values:
1<JSONTree 2 labelRenderer={raw => <Text style={{ fontWeight: 'bold' }}>{raw}</Text>} 3 valueRenderer={raw => <Text style={{ fontStyle: 'italic' }}>{raw}</Text>} 4/>
In this example the label and value will be rendered with bold and italic text respectively.
For labelRenderer
, you can provide a full path - see this PR.
More Options
shouldExpandNode: (keyName, data, level) => boolean
- determines if node should be expanded (root is expanded by default)hideRoot: boolean
- iftrue
, the root node is hidden.sortObjectKeys: boolean | (a, b) => number
- sorts object keys with compare function (optional). Isn't applied to iterable maps likeImmutable.Map
.
Credits
License
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.md:0
Reason
4 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 6
Reason
Found 10/21 approved changesets -- score normalized to 4
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 19 are checked with a SAST tool
Reason
69 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-f5x2-xv93-4p23
- Warn: Project is vulnerable to: GHSA-gmpm-xp43-f7g6
- Warn: Project is vulnerable to: GHSA-pf27-929j-9pmm
- Warn: Project is vulnerable to: GHSA-327c-qx3v-h673
- Warn: Project is vulnerable to: GHSA-x4cf-6jr3-3qvp
- Warn: Project is vulnerable to: GHSA-mph8-6787-r8hw
- Warn: Project is vulnerable to: GHSA-7mhc-prgv-r3q4
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-xvf7-4v9q-58w6
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-x565-32qp-m3vf
- Warn: Project is vulnerable to: GHSA-4cpg-3vgw-4877
- Warn: Project is vulnerable to: GHSA-rxrc-rgv4-jpvx
- Warn: Project is vulnerable to: GHSA-7f53-fmmv-mfjv
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-gff7-g5r8-mg8m
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-hh27-ffr2-f2jc
- Warn: Project is vulnerable to: GHSA-rqff-837h-mm52
- Warn: Project is vulnerable to: GHSA-8v38-pw62-9cw2
- Warn: Project is vulnerable to: GHSA-hgjh-723h-mx2j
- Warn: Project is vulnerable to: GHSA-jf5r-8hm2-f872
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc
- Warn: Project is vulnerable to: GHSA-5fg8-2547-mr8q
- Warn: Project is vulnerable to: GHSA-crh6-fp67-6883
- Warn: Project is vulnerable to: GHSA-c2jc-4fpr-4vhg
- Warn: Project is vulnerable to: GHSA-q8pj-2vqx-8ggc
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm
- Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574
- Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm
- Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-566m-qj78-rww5
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-x3m3-4wpv-5vgc
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
- Warn: Project is vulnerable to: GHSA-2m39-62fm-q8r3
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-5v72-xg48-5rpm
Score
3
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More