{"id":16118221,"url":"https://github.com/zacharygolba/jsonptr","last_synced_at":"2025-04-06T09:46:06.732Z","repository":{"id":57170257,"uuid":"171322318","full_name":"zacharygolba/jsonptr","owner":"zacharygolba","description":"Read and write values to locations referenced by JSON pointers as described in RFC 6901","archived":false,"fork":false,"pushed_at":"2019-02-20T18:16:04.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T04:48:53.137Z","etag":null,"topics":["assign","cache","derference","json","pointers","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zacharygolba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-18T16:58:02.000Z","updated_at":"2019-02-20T18:13:01.000Z","dependencies_parsed_at":"2022-08-27T13:11:37.617Z","dependency_job_id":null,"html_url":"https://github.com/zacharygolba/jsonptr","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacharygolba%2Fjsonptr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacharygolba%2Fjsonptr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacharygolba%2Fjsonptr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacharygolba%2Fjsonptr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zacharygolba","download_url":"https://codeload.github.com/zacharygolba/jsonptr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247463812,"owners_count":20942944,"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":["assign","cache","derference","json","pointers","typescript"],"created_at":"2024-10-09T20:48:58.839Z","updated_at":"2025-04-06T09:46:06.674Z","avatar_url":"https://github.com/zacharygolba.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsonptr\n\n[![CircleCI](https://img.shields.io/circleci/project/github/zacharygolba/jsonptr/master.svg?style=flat-square)](https://circleci.com/gh/zacharygolba/jsonptr/tree/master) [![Codecov](https://img.shields.io/codecov/c/github/zacharygolba/jsonptr/master.svg?style=flat-square)](https://codecov.io/gh/zacharygolba/jsonptr/branch/master) [![npm](https://img.shields.io/npm/v/@zakgolba/jsonptr.svg?style=flat-square)](https://www.npmjs.com/package/@zakgolba/jsonptr)\n\nRead and write values to locations referenced by JSON pointers as described in [RFC 6901](https://tools.ietf.org/html/rfc6901).\n\n## Usage\n\n### Installation\n\n```sh\n# If you're using npm\nnpm install @zakgolba/jsonptr --save\n\n# If you're using yarn\nyarn add @zakgolba/jsonptr\n```\n\n### API Documentation\n\n#### assign(operand: object, pointer: string, value: any): boolean\n\nAttempts to write a value to the location that the `pointer` references.\n\nIf the value is stored successfully, the cached pointers for the `target` provided will be invalidated.\n\nReturns a `boolean` that represents whether or not the value was able to be written to the location that the `pointer` references.\n\n```typescript\nimport jsonptr from \"@zakgolba/jsonptr\";\n\nconst data = { hello: {} };\n\njsonptr.assign(data, \"/hello/world\", \"Hello, world!\");\nconsole.log(data.hello.world);\n// =\u003e Hello, world!\n\nconsole.log(jsonptr.assign(data, \"/invalid/reference\", \"Hello, world!\"));\n// =\u003e false\n```\n\n#### compile(tokens: Iterable\\\u003cstring\u003e): string\n\nCompiles and returns a JSON pointer from an iterable of unescaped tokens.\n\n```typescript\nimport jsonptr from \"@zakgolba/jsonptr\";\n\nconsole.log(jsonptr.compile([\"hello\", \"world\"]));\n// =\u003e /hello/world\n\nconsole.log(jsonptr.compile([\"hello/world\", \"pointer\"]));\n// =\u003e /hello~1world/pointer\n```\n\n#### deref(operand: object, pointer: string): unknown\n\nAttempts to read and return the value at the location that the `pointer` references.\n\n```typescript\nimport jsonptr from \"@zakgolba/jsonptr\";\n\nconst data = { hello: { world: \"Hello, world!\" } };\n\nconsole.log(jsonptr.deref(data, \"/hello/world\"));\n// =\u003e Hello, world!\nconsole.log(jsonptr.deref(data, \"/this/points/nowhere\"));\n// =\u003e undefined\n```\n\n#### parse(pointer: string): IterableIterator\\\u003cstring\u003e\n\nLazily parses and unescapes each token in the provided `pointer`.\n\n```typescript\nimport jsonptr from \"@zakgolba/jsonptr\";\n\nconsole.log([...jsonptr.parse(\"/hello/world\")]);\n// =\u003e [\"hello\", \"world\"]\n\nfor (const token of jsonptr.parse(\"/hello~1world/pointer\")) {\n  console.log(token);\n}\n// =\u003e hello/world\n// =\u003e pointer\n```\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0\n  ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license\n  ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzacharygolba%2Fjsonptr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzacharygolba%2Fjsonptr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzacharygolba%2Fjsonptr/lists"}