{"id":17949731,"url":"https://github.com/slurmulon/json-where","last_synced_at":"2025-03-24T23:32:02.853Z","repository":{"id":46184735,"uuid":"56906724","full_name":"slurmulon/json-where","owner":"slurmulon","description":":mag: Transparent query, pointer and path descriptors for JSON","archived":false,"fork":false,"pushed_at":"2022-12-05T10:36:18.000Z","size":378,"stargazers_count":16,"open_issues_count":6,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-29T10:07:03.211Z","etag":null,"topics":["find","json","match","pattern","query","xpath"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/slurmulon.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}},"created_at":"2016-04-23T07:36:24.000Z","updated_at":"2023-12-29T12:50:08.000Z","dependencies_parsed_at":"2023-01-24T04:31:42.010Z","dependency_job_id":null,"html_url":"https://github.com/slurmulon/json-where","commit_stats":null,"previous_names":["slurmulon/json-rel"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slurmulon%2Fjson-where","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slurmulon%2Fjson-where/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slurmulon%2Fjson-where/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slurmulon%2Fjson-where/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slurmulon","download_url":"https://codeload.github.com/slurmulon/json-where/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245162190,"owners_count":20570692,"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":["find","json","match","pattern","query","xpath"],"created_at":"2024-10-29T09:32:33.664Z","updated_at":"2025-03-24T23:32:02.500Z","avatar_url":"https://github.com/slurmulon.png","language":"JavaScript","funding_links":[],"categories":["Queries"],"sub_categories":[],"readme":"# json-where\n\n\u003e :mag: Transparent query, pointer and path descriptors for JSON\n\n---\n\n`json-where` converges the following standards and libraries in order to help normalize JSON query/addressing descriptors:\n\n - JsonPath\n   * Specification: http://goessner.net/articles/JsonPath/\n   * Library: https://www.npmjs.com/package/jsonpath\n - JsonPointer\n   * Specification: http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-08\n   * Library: https://www.npmjs.com/package/jsonpointer\n - JsonQuery\n   * Library: https://www.npmjs.com/package/json-query\n\nThe goal is to increase developer transparency and to provide a unified interface for matching related JSON data.\n\n`json-where`'s simple interface spares developers from having to:\n\n  1. decide between which query/addressing specifications(s) to support in their projects\n  2. write an interface for when more than one standard needs support\n  3. bottleneck integrators of their library into a certain specificaton\n  4. write a mechanism that provides a consistent return format (e.g. array vs. element)\n\n## Installation\n\n`npm install json-where`\n\n## Usage\n\n### Implicit\n\nThis example shows how to use the main feature of `json-where`, which is being able to provide any descriptor string to `$`.\n\nThe `$` \"operator\" will automatically imply the correct specification to use based on the descriptor itself:\n\n```javascript\nimport $ from 'json-where'\n\nconst data = {\n  foo: {\n    bar: 'baz'\n  }\n}\n\nlet query   = $('foo.bar').use(data).get()   // 'baz'\nlet path    = $('$.foo.bar').use(data).get() // 'baz'\nlet pointer = $('/foo/bar').use(data).get()  // 'baz'\n```\n\nIf you want to be slightly more concise you can avoid calling `use`:\n\n```javascript\nlet query   = $('foo[bar]', data).get()  // 'baz'\nlet path    = $('$.foo.bar', data).get() // 'baz'\nlet pointer = $('/foo/bar', data).get()  // 'baz'\n```\n\n### Explicit\n\nYou may also, of course, access and use each specification individually:\n\n```javascript\nimport { query, path, pointer } from 'json-where'\n\nquery('foo[bar]', data).get()   // 'baz'\npath('$.foo.bar', data).get()   // 'baz'\npointer('/foo/bar', data).get() // 'baz'\n```\n\n### Collections\n\nYou can easily specify whether or not you should expect a single object or a collection:\n\n```javascript\n$('foo[bar]', data).one() // 'baz'\n$('foo[bar]', data).all() // ['baz']\n```\n\nA couple of common utility methods are also defined for working with collections:\n\n```javascript\n$('foo[bar]', data).count() // 1\n$('foo[bar]', data).any()   // true\n$('bar[baz]', data).any()   // false\n```\n\n### Identification\n\nYou can infer the specification directly from the descriptor itself via `which`:\n\n```javascript\nwhich('foo[bar]')  // 'json-query'\nwhich('$.foo.bar') // 'json-path'\nwhich('/foo/bar')  // 'json-pointer'\n```\n\n### Update\n\nCurrently only `json-pointer` supports updating values via descriptors:\n\n```javascript\nconst path = pointer('/foo/bar', data)\n\npath.get()      // 'bar'\npath.set('zab') // ...\npath.get()      // 'zab'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslurmulon%2Fjson-where","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslurmulon%2Fjson-where","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslurmulon%2Fjson-where/lists"}