{"id":29408242,"url":"https://github.com/stefanhengl/fields","last_synced_at":"2025-07-11T02:30:20.719Z","repository":{"id":62432644,"uuid":"200398480","full_name":"stefanhengl/fields","owner":"stefanhengl","description":"Like select-keys but for nested maps","archived":false,"fork":false,"pushed_at":"2019-08-18T04:57:46.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-09T02:12:11.755Z","etag":null,"topics":["clojure","fields","filter","nested","select-keys"],"latest_commit_sha":null,"homepage":"","language":"Clojure","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/stefanhengl.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":"2019-08-03T16:41:15.000Z","updated_at":"2019-08-18T04:57:44.000Z","dependencies_parsed_at":"2022-11-01T21:15:56.000Z","dependency_job_id":null,"html_url":"https://github.com/stefanhengl/fields","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/stefanhengl/fields","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanhengl%2Ffields","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanhengl%2Ffields/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanhengl%2Ffields/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanhengl%2Ffields/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefanhengl","download_url":"https://codeload.github.com/stefanhengl/fields/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanhengl%2Ffields/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264361020,"owners_count":23596236,"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":["clojure","fields","filter","nested","select-keys"],"created_at":"2025-07-11T02:30:17.579Z","updated_at":"2025-07-11T02:30:20.630Z","avatar_url":"https://github.com/stefanhengl.png","language":"Clojure","readme":"# fields [![Build Status](https://travis-ci.com/stefanhengl/pdfsplit.svg?branch=master)](https://travis-ci.com/stefanhengl/pdfsplit)\n\n`fields` exposes the function `select-keys-by-fields` which offers the\nsame functionality as\n[select-keys](https://clojuredocs.org/clojure.core/select-keys) but\nfor complex nested maps. Instead of specifying paths in a vector, we write a query\ndescribing the structure of the desired output map.\n\n`fields`is inspired by the same-named HTTP request parameter as\ndescribed by Google\n[here](https://developers.google.com/drive/api/v3/performance). In the\nbackground it parses the query into a\n[zipper](https://clojuredocs.org/clojure.zip) and traverses the zipper\nfiltering the map along the way.\n\n## Example\n\n```clojure\n(def data {:a 1\n\t   :b [{:aa 2 :bb 3} {:aa 4 :bb 5}]\n\t   :c {:cc 6 :dd {:fff 7 :ggg 8}}})\n\n(select-keys-by-fields data \"(a)\")\n=\u003e {:a 1}\n\n(select-keys-by-fields data \"(a,b(aa))\")\n=\u003e {:a 1, :b ({:aa 2} {:aa 4})}\n\n(select-keys-by-fields data \"(b,c(cc,dd(ggg)))\")\n=\u003e {:b ({:aa 2, ::bb 3} {:aa 4, :bb 5}), :c {:cc 6, :dd {:ggg 8}}}\n```\n\nThe parser which parses a query string and outputs a zipper is a pure function that is worth caching whenever you have many differnt maps but only a small set of queries. For such use cases you can just memozie the parser and use `select-keys-by-zipper` instead of `select-keys-by-fields`.\n\n``` clojure\n(def parse-memo (memoize parse))\n(select-keys-by-zipper data (parse-memo \"(a,b(aa))\"))\n=\u003e {:a 1, :b ({:aa 2} {:aa 4})}\n```\n\n## Latest Version\n\n[![Clojars Project](https://img.shields.io/clojars/v/fields.svg)](https://clojars.org/fields)\n\n## License\n MIT\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanhengl%2Ffields","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanhengl%2Ffields","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanhengl%2Ffields/lists"}