{"id":24568178,"url":"https://github.com/yysuni/react18-json-view","last_synced_at":"2025-05-14T20:08:52.364Z","repository":{"id":156522753,"uuid":"633029366","full_name":"YYsuni/react18-json-view","owner":"YYsuni","description":"JSON viewer for react18","archived":false,"fork":false,"pushed_at":"2025-02-19T13:14:11.000Z","size":1560,"stargazers_count":296,"open_issues_count":34,"forks_count":29,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T00:05:49.576Z","etag":null,"topics":["function-component","interactive-json","json-display","json-view","react","react-json","react18"],"latest_commit_sha":null,"homepage":"https://jv.yysuni.com/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YYsuni.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-26T16:17:06.000Z","updated_at":"2025-04-01T18:30:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"987b550a-82e9-41f1-a2f9-b01a9a491cbd","html_url":"https://github.com/YYsuni/react18-json-view","commit_stats":{"total_commits":208,"total_committers":13,"mean_commits":16.0,"dds":0.4375,"last_synced_commit":"1e5636d30f445f1378d164b816a5689982408d76"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YYsuni%2Freact18-json-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YYsuni%2Freact18-json-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YYsuni%2Freact18-json-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YYsuni%2Freact18-json-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YYsuni","download_url":"https://codeload.github.com/YYsuni/react18-json-view/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248351729,"owners_count":21089333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["function-component","interactive-json","json-display","json-view","react","react-json","react18"],"created_at":"2025-01-23T14:20:01.353Z","updated_at":"2025-04-11T06:19:08.401Z","avatar_url":"https://github.com/YYsuni.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [React18 JSON View](https://jv.yysuni.com/)\n\n\u003cp \u003e\n  \u003ca href=\"https://www.npmjs.com/package/react18-json-view\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/react18-json-view.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/react18-json-view\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dm/react18-json-view.svg\" /\u003e\n  \u003c/a\u003e\n    \u003ca href=\"https://github.com/YYsuni/react18-json-view/blob/main/LICENSE\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/l/react18-json-view.svg\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nReact function component for displaying javascript arrays and JSON objects. Supports all JS types.\n\n[Website](https://jv.yysuni.com/), [Storybook](https://react18-json-view.vercel.app/),[Online](https://json-view-online.vercel.app/)\n\n![JSON View](sample.png 'JSON View')\n\n## Installation\n\n```bash\nnpm i react18-json-view\n```\n\n```bash\nnpm i react18-json-view@canary\n```\n\n## Usage\n\n```tsx\nimport JsonView from 'react18-json-view'\nimport 'react18-json-view/src/style.css'\n// If dark mode is needed, import `dark.css`.\n// import 'react18-json-view/src/dark.css'\n\n\u003cJsonView src={my_json_object} /\u003e\n\n// If needed, you can use the internal stringify function.\n// import { stringify } from 'react18-json-view'\n```\n\n### Props\n\n| Name                                                    | Type                                                                                                                              | Default                                                                                             | Description                                                                                                                                                                                    |\n| :------------------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `src`                                                   | `JSON Object`                                                                                                                     | None                                                                                                | \u003cdiv style=\"min-width: 200px\"\u003e This property contains your input JSON \u003c/div\u003e                                                                                                                   |\n| `className`                                             | `string`                                                                                                                          | None                                                                                                | The CSS class name(s) to apply to the component.                                                                                                                                               |\n| `style`                                                 | `JSON Object`                                                                                                                     | None                                                                                                | An object containing custom style rules to apply to the component.                                                                                                                             |\n| `dark`                                                  | `boolean`                                                                                                                         | `false`                                                                                             | Keep in dark mode (Don't forget to import `dark.css`)                                                                                                                                          |\n| `theme`                                                 | `default` \\| `a11y` \\| `github` \\| `vscode` \\| `atom`\\|`winter-is-coming`                                                         | `'default'`                                                                                         | Color theme                                                                                                                                                                                    |\n| `enableClipboard`                                       | `boolean`                                                                                                                         | `true`                                                                                              | Whether enable clipboard feature.                                                                                                                                                              |\n| `matchesURL`                                            | `boolean`                                                                                                                         | `true`                                                                                              | Show the link icon if value is string and matches URL regex pattern.                                                                                                                           |\n| `urlRegExp`                                             | `RegExp`                                                                                                                          | `/^(((ht\\|f)tps?):\\/\\/)?([^!@#$%^\u0026*?.\\s-]([^!@#$%^\u0026*?.\\s]{0,63}[^!@#$%^\u0026*?.\\s])?\\.)+[a-z]{2,6}\\/?/` | URL RegExp pattern.                                                                                                                                                                            |\n| `displaySize`                                           | `boolean` \\| `integer` \\| 'collapsed' \\| 'expanded'                                                                               | `false`                                                                                             | Whether display the size of `Object`, `Array`.                                                                                                                                                 |\n| `displayArrayIndex`                                     | `boolean`                                                                                                                         | `true`                                                                                              | Whether display the index of `Array`.                                                                                                                                                          |\n| `collapseStringsAfterLength`                            | `integer`                                                                                                                         | `99`                                                                                                | When an integer value is assigned, strings longer than that length will be truncated and indicated by an ellipsis. To expand or collapse the string content, simply click on the string value. |\n| `customizeCollapseStringUI`                             | ` (str_show: string, truncated: boolean) =\u003e (JSX.Element \\| string)` \\| `string`                                                  | -                                                                                                   | Customize the collapse string UI.                                                                                                                                                              |\n| `ignoreLargeArray`                                      | `boolean`                                                                                                                         | `false`                                                                                             | Prevent collapsing large array(length \u003e 100) behavior since v0.2.7                                                                                                                             |\n| `collapseStringMode`                                    | `'directly'` \\| `'word'` \\| `'address'`                                                                                           | `'directly'`                                                                                        | If the `word` is assigned, the collapsed length will be adjusted to fully display the last word.                                                                                               |\n| `collapsed`                                             | `boolean` \\| `integer` \\| `function`                                                                                              | `false`                                                                                             | When set to true(false), all nodes will be (not) collapsed by default. When using an integer value, it will collapse at a specific depth. The collapsed also can be a function.                |\n| `onCollapse`                                            | `function`                                                                                                                        | -                                                                                                   | `(params: { isCollapsing: boolean, node: Record\u003cstring, any\u003e \\| Array\u003cany\u003e, indexOrName: string \\| number \\| undefined, depth: number }) =\u003e void`                                              |\n| `collapseObjectsAfterLength`                            | `integer`                                                                                                                         | `99`                                                                                                | When an integer value is assigned, the object and array will initially collapse.                                                                                                               |\n| `editable`                                              | `boolean` \\| {add?: `boolean`, edit?: `boolean`, delete?: `boolean`}                                                              | `false`                                                                                             | When set to true, you can add, edit, or delete the property, and the actions will trigger onAdd, onEdit, or onDelete. Options is available.                                                    |\n| `onAdd`                                                 | `function`                                                                                                                        | -                                                                                                   | `(params: { indexOrName: string\\| number, depth: number, src: any; parentType: 'object' \\| 'array' }) =\u003e void`                                                                                 |\n| `onDelete`                                              | `function`                                                                                                                        | -                                                                                                   | `(params:{ value: any,indexOrName: string \\| number,depth: number,src: any,parentType: 'object' \\| 'array'}) =\u003e void`                                                                          |\n| `onEdit`                                                | `function`                                                                                                                        | -                                                                                                   | `(params: { newValue: any, oldValue: any, depth: number, src: any, indexOrName: string \\| number, parentType: 'object' \\| 'array'}) =\u003e void`                                                   |\n| `customizeNode`                                         | `ReactElement`\\|`ReactComponent`\\|`Options`                                                                                       | -                                                                                                   | Highly customize every node.                                                                                                                                                                   |\n| `customizeCopy`                                         | `(node: any, nodeMeta: NodeMeta) =\u003e any`                                                                                          | internal stringify                                                                                  | Customize copy behavior, only the returned non-empty string will be written to clipboard.                                                                                                      |\n| `CopyComponent` \\/ `DoneComponent` \\/ `CancelComponent` | `React.FC` \\/ `React.Component` `\u003c{ onClick: (event: React.MouseEvent) =\u003e void; className: string ; style: React.CSSProperties}\u003e` | -                                                                                                   | Customize copy icon.                                                                                                                                                                           |\n| `CopiedComponent`                                       | `React.FC` \\/ `React.Component` `\u003c{ className: string; style: React.CSSProperties }\u003e`                                             | -                                                                                                   | Customize copied icon.                                                                                                                                                                         |\n| `CustomOperation`                                       | `React.FC` \\/ `React.Component` `\u003c{ node: any }\u003e`                                                                                 | -                                                                                                   | Custom Operation                                                                                                                                                                               |\n\n### Collapsed function\n\n```ts\n;(params: {\n\tnode: Record\u003cstring, any\u003e | Array\u003cany\u003e // Object or array\n\tindexOrName: number | string | undefined\n\tdepth: number\n\tsize: number // Object's size or array's length\n}) =\u003e boolean\n```\n\n### Editable options\n\n```ts\n{\n  add?: boolean\n  edit?: boolean\n  delete?: boolean\n}\n```\n\n\u003e onEdit, OnDelete, onAdd and OnChange add `parentPath` field, allow us to correctly indicate which field in the JSON is being edited.\n\n### CustomizeNode\n\n```ts\n(params: { node: any; indexOrName: number | string | undefined; depth: number }) =\u003e\n  | {\n    add?: boolean\n    edit?: boolean\n    delete?: boolean\n    enableClipboard?: boolean\n    collapsed?: boolean\n    className?: string\n  }\n  | React.FC\n  | typeof React.Component\n  | React.ReactElement\u003cany, any\u003e\n```\n\n### NodeMeta\n\n```ts\n{ depth: number; indexOrName?: number | string; parent?: Record\u003cstring, any\u003e | Array\u003cany\u003e; parentPath: string[], currentPath: string[] }\n```\n\n## Editable\n\n### How to generate object/array\n\nThe editor uses `JSON.parse(\u003cinput-value\u003e)`. While in edit mode, you can enter `({})` or `([])`, which will cause the result of eval to become a new object or array.\n\n\u003e `{}` and `[]` will be auto convert to `({})`,`([])`\n\n### How the editor works\n\nThis component does not perform any cloning operations, so every step of the operation is carried out on the original object. If cloning is required, please handle it yourself.\n\n### Edit keyboard shortcuts\n\nWhen element is editable:\n\n- `Ctrl/Cmd+Click` =\u003e Edit Mode\n- `Enter` =\u003e Submit\n- `Esc` =\u003e Cancel\n\n## Custom themes\n\nBelow are the default theme variables that you can easily customize to fit your needs.\n\n```css\n.json-view {\n\tcolor: #4d4d4d;\n\t--json-property: #009033;\n\t--json-index: #676dff;\n\t--json-number: #676dff;\n\t--json-string: #b2762e;\n\t--json-boolean: #dc155e;\n\t--json-null: #dc155e;\n}\n.json-view .json-view--property {\n\tcolor: var(--json-property);\n}\n.json-view .json-view--index {\n\tcolor: var(--json-index);\n}\n.json-view .json-view--number {\n\tcolor: var(--json-number);\n}\n.json-view .json-view--string {\n\tcolor: var(--json-string);\n}\n.json-view .json-view--boolean {\n\tcolor: var(--json-boolean);\n}\n.json-view .json-view--null {\n\tcolor: var(--json-null);\n}\n```\n\n## Why\n\nreact-json-view does not support React 18.\n\n## Todo\n\n- [x] copy (enableClipboard)\n- [x] css\n- [x] collapse at a particular depth (collapsed)\n- [x] editable\n  - [x] add\n  - [x] edit\n  - [x] delete\n  - [x] onChange\n  - [ ] onSelect\n- [x] dark mode\n- [x] custom icon\n  - [x] export default icons\n- [x] more usability/scenarios\n- [ ] gif guide\n- [x] more color themes(dark)\n- [x] collapse objects callback\n- [x] editable option\n- [x] advance customization\n  - [ ] access internal actions\n- [ ] map/set viewer\n- [ ] display data type\n- [x] display object size\n- [ ] handle circle loop\n- [x] redesign docs\n- [x] truncate long strings\n- [x] custom `stringify`\n- [x] split large array\n\n* tree?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyysuni%2Freact18-json-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyysuni%2Freact18-json-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyysuni%2Freact18-json-view/lists"}