{"id":13526343,"url":"https://github.com/aligay/jsonuri","last_synced_at":"2025-04-05T17:05:36.667Z","repository":{"id":37651410,"uuid":"61267698","full_name":"aligay/jsonuri","owner":"aligay","description":"🌳 阿里剑鱼、iceluna、vanex 数据操作底层库，使用O(n) 复杂度回溯祖先节点","archived":false,"fork":false,"pushed_at":"2024-05-06T07:15:14.000Z","size":1380,"stargazers_count":152,"open_issues_count":2,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-29T16:05:22.392Z","etag":null,"topics":["insert","jsonpath","nullcheck","swap"],"latest_commit_sha":null,"homepage":"https://jsonuri.js.org/","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/aligay.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-16T06:24:27.000Z","updated_at":"2025-03-16T13:44:31.000Z","dependencies_parsed_at":"2023-12-20T14:13:10.405Z","dependency_job_id":"c84e1924-f128-4e0b-9ca8-f3ff2cdd6490","html_url":"https://github.com/aligay/jsonuri","commit_stats":{"total_commits":80,"total_committers":7,"mean_commits":"11.428571428571429","dds":0.1875,"last_synced_commit":"99b3a9814cf81da21eba876e370f742a7f520161"},"previous_names":["height/jsonuri"],"tags_count":68,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aligay%2Fjsonuri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aligay%2Fjsonuri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aligay%2Fjsonuri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aligay%2Fjsonuri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aligay","download_url":"https://codeload.github.com/aligay/jsonuri/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369952,"owners_count":20927928,"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":["insert","jsonpath","nullcheck","swap"],"created_at":"2024-08-01T06:01:28.283Z","updated_at":"2025-04-05T17:05:36.646Z","avatar_url":"https://github.com/aligay.png","language":"TypeScript","readme":"# JSON URI\n\n---\n\n`Use URI style methods to operate data.`\nAll operations friendly support Vue-like frameworks.\n\n[![Build Status](https://travis-ci.com/aligay/jsonuri.svg?branch=master)](https://travis-ci.com/github/aligay/jsonuri/branches)\n[![codecov](https://codecov.io/gh/aligay/jsonuri/branch/master/graph/badge.svg)](https://codecov.io/gh/aligay/jsonuri/branch/master)\n[![npm](https://img.shields.io/npm/v/jsonuri.svg)](https://www.npmjs.com/package/jsonuri)\n[![dependencies Status](https://david-dm.org/aligay/jsonuri/status.svg)](https://david-dm.org/aligay/jsonuri)\n[![devDependencies Status](https://david-dm.org/aligay/jsonuri/dev-status.svg)](https://david-dm.org/aligay/jsonuri?type=dev)\n\n## Use\n\n```shell\n$ npm install jsonuri --save\n```\n\n```javascript\nimport * as jsonuri from 'jsonuri'\n// or\nimport { get, set, ... } from 'jsonuri' // recommended practice, friendly to tree-shaking\n```\n\n### Example Data:\n```json\n{\n  \"menu\": {\n    \"id\": 123,\n    \"list\": [0, 1, 2, 3, 4],\n    \"popup\": {\n      \"menuitem\": [{\n          \"value\": \"New\",\n          \"onclick\": \"CreateNewDoc()\"\n        },\n        {\n          \"value\": \"Open\",\n          \"onclick\": \"OpenDoc()\"\n        },\n        {\n          \"value\": \"Close\",\n          \"onclick\": \"CloseDoc()\"\n        }\n      ]\n    }\n  }\n}\n\n```\n\n## Methods:\n\n### get (data, path)\nGet the value of the specified data for the path.\n\n\n**Example:**\n\n```javascript\njsonuri.get(data, 'menu/id')\n// return 123\n\njsonuri.get(data, 'menu/popup/menuitem/0/value')\n// return 'New'\n\njsonuri.get(data, 'menu/popup/menuitem/0/value/..')\n// {value: \"New\", onclick: \"CreateNewDoc()\"}\n\n```\n[see more](test/spec/get_spec.js)\n### set (data, path, value)\nSet the value of the specified data for the path.\n\n**Example:**\n\n```javascript\njsonuri.set(data, 'menu/id/', 789)\njsonuri.get(data, 'menu/id')\n//789\n\n```\n[see more](test/spec/set_spec.js)\n\n### rm (data, path)\nRemove the value of the specified data for the path.\n\n**Example:**\n\n```javascript\njsonuri.rm(data, 'menu/id')\njsonuri.get(data, 'menu/id') // undefined\n```\n[see more](test/spec/rm_spec.js)\n\n\n### mv (data, pathA, pathB, sequence)\nData A moved to target B before or after.\n\n**Example:**\n\n```javascript\njsonuri.mv(data, 'menu/list/0', 'menu/list/3')\njsonuri.get(data, 'menu/list') // [1, 2, 3, 0, 4]\n[see more](test/spec/mv_spec.js)\n\n\njsonuri.set(data, 'menu/list/',[0,1,2,3,4])\njsonuri.mv(data, 'menu/list/0', 'menu/list/3', 'before')\njsonuri.get(data, 'menu/list') // [1, 2, 0, 3, 4]\n\n```\n[see more](test/spec/mv_spec.js)\n\n### swap (data, pathA, pathB)\nData swap in an array.\n\n**Example:**\n\n```javascript\njsonuri.swap(data, 'menu/list/0', 'menu/list/4')\njsonuri.get(data, 'menu/list') // [4, 1, 2, 3, 0]\n\njsonuri.swap(data, 'menu/list/0', 'menu/list/4')\njsonuri.get(data, 'menu/list') // [4, 1, 2, 3, 0]\n\n```\n[see more](test/spec/swap_spec.js)\n\n\n### insert (data, pathA, value, direction)\n\nInsert data into an `array` that is described in the path.\n\n**Example:**\n\n```javascript\njsonuri.insert(data, 'menu/list/0', 9999, 'before') // [9999, 0, 1, 2, 3, 4]\n\n```\n[see more](test/spec/insert_spec.js)\n\n\n### up(data, path, gap)\n[see more](test/spec/up_spec.js)\n\n\n### down(data, path, gap)\n\n[see more](test/spec/down_spec.js)\n\n\n### walk(data, descentionFn, ascentionFn)\nTraverse each data of each node and value.\n\n**Example:**\n\n```javascript\njsonuri.walk({a:{a1:'x'}}, (value, key, parent, { path }) =\u003e {\n  console.log(value, key, parent, path)\n})\n\n// { a1: 'x' } 'a' { a: { a1: 'x' } } 'a'\n// x a1 { a1: 'x' } 'a/a1'\n```\n[see more](test/spec/walk_spec.js)\n\n### normalizePath(path1, path2, ...)\n\n**Example:**\n\n```javascript\njsonuri.normalizePath('a', 'b') // a/b\n\njsonuri.normalizePath(['a', 'b', '../'], 'c') // a/c\n\n\n```\n[see more](test/spec/normalizePath_spec.js)\n\n### isCircular(obj)\n\n**Example:**\n\n```javascript\njsonuri.isCircular({}) // return false\njsonuri.isCircular(window) // return true\n\nvar a = {}\njsonuri.set(a, '/b/c/d/e/f/g', a)\njsonuri.isCircular(a) // return true\n\n\n```\n[see more](test/spec/isCircular_spec.js)\n","funding_links":[],"categories":["Repository"],"sub_categories":["Object / JSON / JSON Schema"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faligay%2Fjsonuri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faligay%2Fjsonuri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faligay%2Fjsonuri/lists"}