{"id":16761257,"url":"https://github.com/irevoire/permissive-json-pointer","last_synced_at":"2025-04-10T17:51:54.318Z","repository":{"id":57654289,"uuid":"476495780","full_name":"irevoire/permissive-json-pointer","owner":"irevoire","description":"A permissive json pointer","archived":false,"fork":false,"pushed_at":"2022-04-06T20:15:41.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T04:32:00.281Z","etag":null,"topics":["json","json-path","json-pointer","permissive","serde-json"],"latest_commit_sha":null,"homepage":"https://docs.rs/permissive-json-pointer/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/irevoire.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2022-03-31T22:19:28.000Z","updated_at":"2022-04-06T20:14:28.000Z","dependencies_parsed_at":"2022-09-01T01:12:18.959Z","dependency_job_id":null,"html_url":"https://github.com/irevoire/permissive-json-pointer","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irevoire%2Fpermissive-json-pointer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irevoire%2Fpermissive-json-pointer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irevoire%2Fpermissive-json-pointer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irevoire%2Fpermissive-json-pointer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/irevoire","download_url":"https://codeload.github.com/irevoire/permissive-json-pointer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248262433,"owners_count":21074308,"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":["json","json-path","json-pointer","permissive","serde-json"],"created_at":"2024-10-13T04:42:09.413Z","updated_at":"2025-04-10T17:51:54.295Z","avatar_url":"https://github.com/irevoire.png","language":"Rust","readme":"# Permissive json pointer\n\nThis crate provide an interface a little bit similar to what you know as “json pointer”.\nBut it’s actually doing something quite different.\n\n## The API\n\nThe crate provide only one function called [`select_values`].\nIt takes one object in parameter and a list of selectors.\nIt then returns a new object containing only the fields you selected.\n\n## The selectors\n\nThe syntax for the selector is easier than with other API.\nThere is only ONE special symbol, it’s the `.`.\n\nIf you write `dog` and provide the following object;\n```json\n{\n  \"dog\": \"bob\",\n  \"cat\": \"michel\"\n}\n```\nYou’ll get back;\n```json\n{\n  \"dog\": \"bob\",\n}\n```\n\nEasy right?\n\nNow the dot can either be used as a field name, or as a nested object.\n\nFor example, if you have the following json;\n```json\n{\n  \"dog.name\": \"jean\",\n  \"dog\": {\n    \"name\": \"bob\",\n    \"age\": 6\n  }\n}\n```\n\nWhat a crappy json! But never underestimate your users, they [_WILL_](https://xkcd.com/1172/)\nsomehow base their entire workflow on this kind of json.\nHere with the `dog.name` selector both fields will be\nselected and the following json will be returned;\n```json\n{\n  \"dog.name\": \"jean\",\n  \"dog\": {\n    \"name\": \"bob\",\n  }\n}\n```\n\nAnd as you can guess, this crate is as permissive as possible.\nIt’ll match everything it can!\nConsider this even more crappy json;\n```json\n{\n  \"pet.dog.name\": \"jean\",\n  \"pet.dog\": {\n    \"name\": \"bob\"\n  },\n  \"pet\": {\n    \"dog.name\": \"michel\"\n    \"dog\": {\n      \"name\": \"milan\"\n    }\n  }\n}\n```\nIf you write `pet.dog.name` everything will be selected.\n\n## Matching arrays\n\nWith this kind of selectors you can’t match a specific element in an array.\nYour selector will be applied to all the element _in_ the array.\n\nConsider the following json;\n```json\n{\n  \"pets\": [\n    {\n      \"animal\": \"dog\",\n      \"race\": \"bernese mountain\",\n    },\n    {\n      \"animal\": \"dog\",\n      \"race\": \"golden retriever\",\n    },\n    {\n      \"animal\": \"cat\",\n      \"age\": 8,\n    }\n  ]\n}\n```\n\nWith the filter `pets.animal` you’ll get;\n```json\n{\n  \"pets\": [\n    {\n      \"animal\": \"dog\",\n    },\n    {\n      \"animal\": \"dog\",\n    },\n    {\n      \"animal\": \"cat\",\n    }\n  ]\n}\n```\n\nThe empty element in an array gets removed. So if you were to look\nfor `pets.age` you would only get;\n```json\n{\n  \"pets\": [\n    {\n      \"age\": 8,\n    }\n  ]\n}\n```\n\nAnd I think that’s all you need to know 🎉\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firevoire%2Fpermissive-json-pointer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firevoire%2Fpermissive-json-pointer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firevoire%2Fpermissive-json-pointer/lists"}