{"id":13447401,"url":"https://github.com/luyuan/json-tree-view","last_synced_at":"2025-03-21T17:31:24.486Z","repository":{"id":57159785,"uuid":"104190297","full_name":"luyuan/json-tree-view","owner":"luyuan","description":"JavaScript JSON explorer with styles similar to Chrome's devtools","archived":false,"fork":true,"pushed_at":"2019-07-19T23:11:10.000Z","size":505,"stargazers_count":56,"open_issues_count":3,"forks_count":18,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-28T11:46:54.211Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"richard-livingston/json-view","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luyuan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-20T08:49:49.000Z","updated_at":"2024-07-29T07:25:40.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/luyuan/json-tree-view","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luyuan%2Fjson-tree-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luyuan%2Fjson-tree-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luyuan%2Fjson-tree-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luyuan%2Fjson-tree-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luyuan","download_url":"https://codeload.github.com/luyuan/json-tree-view/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244838200,"owners_count":20518803,"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":[],"created_at":"2024-07-31T05:01:16.565Z","updated_at":"2025-03-21T17:31:24.179Z","avatar_url":"https://github.com/luyuan.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# JSONTreeView\n\nA simple JSON viewer with basic edit capabilities. It has styles similar to Chrome's dev tools, so it's perfect for building dev tools extensions... **[live example](https://luyuan.github.io/json-tree-view)**.\n\n### Install with NPM\n`npm i json-tree-view`\n\n### Build example\n`./example/build.sh`\nSee ./example/build directory.\n\n### Basic usage\n\n*index.js*\n```js\nvar JSONTreeView = require('json-tree-view');\n\nvar view = new JSONTreeView('example', {\n    hello : 'world',\n    doubleClick : 'me to edit',\n    a : null,\n    b : true,\n    c : false,\n    d : 1,\n    e : {nested : 'object'},\n    f : [1,2,3]\n});\n\n// Listen for change events\nview.on('change', function(self, key, oldValue, newValue){\n    console.log('change', key, oldValue, '=\u003e', newValue);\n});\nview.on('rename', function(self, key, oldName, newName) {\n    console.log('rename', key, oldName, '=\u003e', newName);\n});\nview.on('delete', function(self, key) {\n    console.log('delete', key);\n});\nview.on('append', function(self, key, nameOrValue, newValue) {\n    console.log('append', key, nameOrValue, '=\u003e', newValue);\n});\nview.on('click', function(self, key, value) {\n    console.log('click', key, '=', value);\n});\nview.on('expand', function(self, key, value) {\n    console.log('expand', key, '=', value);\n});\nview.on('collapse', function(self, key, value) {\n    console.log('collapse', key, '=', value);\n});\nview.on('refresh', function(self, key, value) {\n    console.log('refresh', key, '=', value);\n});\n\n// Expand recursively\nview.expand(true);\n\nview.withRootName = false;\n\n// Inspect window.data on the console and note that it changes with edits.\nwindow.data = view.value;\n\nview.value.f.pop()\nview.value.f.push(9)\nview.value.e.a = 'aaa';\ndelete view.value.c;\nview.refresh();\n\n// Do not hide root.\nview.alwaysShowRoot = true;\n\n// Set readonly when filtering words automatically.\nview.readonlyWhenFiltering = true;\nview.filterText = 'a';\n\n// Remove word filter by setting a false value.\nview.filterText = null;\n\n// Always show count of object or array.\nview.showCountOfObjectOrArray = true;\n\n// Cannot change the value of JSON and remove \"+\" and \"x\" buttons.\nview.readonly = true;\n\ndocument.getElementById('filter').addEventListener('input', function() {\n    view.filterText = this.value;\n});\ndocument.getElementById('root').addEventListener('change', function() {\n    view.alwaysShowRoot = !!this.checked;\n});\ndocument.getElementById('rowf').addEventListener('change', function() {\n    view.readonlyWhenFiltering = !!this.checked;\n});\ndocument.getElementById('ro').addEventListener('change', function() {\n    view.readonly = !!this.checked;\n});\ndocument.getElementById('sc').addEventListener('change', function () {\n    view.showCountOfObjectOrArray = !!this.checked;\n});\n\n```\n\n*index.html* - (**don't forget to include the css**)\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003ctitle\u003eJSONView Example\u003c/title\u003e\n    \u003clink rel=\"stylesheet\" href=\"devtools.css\"\u003e\n    \u003cstyle\u003e\n      ul { user-select:none; }\n    \u003c/style\u003e\n    \u003cscript src=\"index.js\" defer\u003e\u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003ch3\u003eOptions\u003c/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n    \u003clabel for=\"filter\"\u003eFilter: \u003c/label\u003e\n    \u003cinput type=\"text\" id=\"filter\" /\u003e\n  \u003c/li\u003e\n  \u003cli\u003e\n    \u003cinput type=\"checkbox\" id=\"root\" /\u003e\n    \u003clabel for=\"root\"\u003eAlways show root\u003c/label\u003e\n  \u003c/li\u003e\n  \u003cli\u003e\n    \u003cinput type=\"checkbox\" id=\"rowf\" /\u003e\n    \u003clabel for=\"rowf\"\u003eAutomatically set to readonly when filtering\u003c/label\u003e\n  \u003c/li\u003e\n  \u003cli\u003e\n    \u003cinput type=\"checkbox\" id=\"ro\" /\u003e\n    \u003clabel for=\"ro\"\u003eReadonly\u003c/label\u003e\n  \u003c/li\u003e\n  \u003cli\u003e\n    \u003cinput type=\"checkbox\" id=\"sc\" checked /\u003e\n    \u003clabel for=\"sc\"\u003eShow count of Object or Array\u003c/label\u003e\n  \u003c/li\u003e\n\u003c/ul\u003e\n\u003ch3\u003eJSON\u003c/h3\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluyuan%2Fjson-tree-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluyuan%2Fjson-tree-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluyuan%2Fjson-tree-view/lists"}