https://github.com/dansalias/json_pointer
JSON Pointer for Deno (IETF RFC6901).
https://github.com/dansalias/json_pointer
deno json-pointer
Last synced: about 1 month ago
JSON representation
JSON Pointer for Deno (IETF RFC6901).
- Host: GitHub
- URL: https://github.com/dansalias/json_pointer
- Owner: dansalias
- License: mit
- Created: 2021-05-15T22:42:47.000Z (about 5 years ago)
- Default Branch: trunk
- Last Pushed: 2021-08-11T20:32:02.000Z (almost 5 years ago)
- Last Synced: 2026-05-02T16:39:49.957Z (about 2 months ago)
- Topics: deno, json-pointer
- Language: TypeScript
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/dansalias/json_pointer/actions/workflows/test.yml)
Complete implementation of __JSON Pointer__ for __Deno__, as per IETF
[RFC6901](https://datatracker.ietf.org/doc/html/rfc6901)
## Usage
```ts
import * as jp from 'https://deno.land/x/json_pointer/mod.ts'
const obj = {
'foo': ['bar', 'baz'],
'qux': { 'quux': 'quuz' },
}
// jp.get(obj: object, pointer: string): any
jp.get(obj, '/foo/0') // 'bar'
jp.get(obj, '/qux/quux') // 'quuz'
jp.get(obj, '/hello') // undefined
// jp.set(obj: object, pointer: string, value: any): void
jp.set(obj, '/foo/1', 'becue') // obj.foo === ['bar', 'becue']
jp.set(obj, '/foo/-', 'bax') // obj.foo === ['bar', 'becue', 'bax']
jp.set(obj, '/new/path', 'val') // obj.new === { path: 'val' }
```
## Testing
```
git clone https://github.com/dansalias/json_pointer
cd ./json_pointer
deno test
```