{"id":29935015,"url":"https://github.com/enrichman/gofield","last_synced_at":"2026-04-11T21:41:55.896Z","repository":{"id":57603587,"uuid":"81879550","full_name":"enrichman/gofield","owner":"enrichman","description":"Keep light your JSON!","archived":false,"fork":false,"pushed_at":"2017-02-15T22:14:38.000Z","size":71,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-03T09:31:00.645Z","etag":null,"topics":["go","golang","json"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/enrichman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-13T22:40:52.000Z","updated_at":"2019-05-08T09:13:54.000Z","dependencies_parsed_at":"2022-09-01T06:40:15.002Z","dependency_job_id":null,"html_url":"https://github.com/enrichman/gofield","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/enrichman/gofield","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enrichman%2Fgofield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enrichman%2Fgofield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enrichman%2Fgofield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enrichman%2Fgofield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enrichman","download_url":"https://codeload.github.com/enrichman/gofield/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enrichman%2Fgofield/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268448222,"owners_count":24251999,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["go","golang","json"],"created_at":"2025-08-02T20:09:00.626Z","updated_at":"2026-04-11T21:41:50.855Z","avatar_url":"https://github.com/enrichman.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gofield [![Build Status](https://travis-ci.org/enrichman/gofield.svg?branch=master)](https://travis-ci.org/enrichman/gofield)\n\nGofield will reduce your JSON serialized Go struct in a lighter object to keep your client happy!\n\nYou can use the \"Facebook convention\" in order to select the fields object: comma separated values, with curly brackets for the inner objects.\n\n```go\nfields := \"foo,bar{inner_foo,inner_bar}\"\nlighterObj := gofield.Reduce(fatObj, fields)\n```\n\ni.e.:\n\nif you have a JSON like\n\n```json\n{\n    \"name\": \"Enrico\",\n    \"surname\": \"Candino\",\n    \"age\": 27,\n    \"city\": \"Rome\",\n    \"email\":[\n        {\n            \"name\": \"work\",\n            \"email\": \"mymail@work.it\"\n        },\n        {\n            \"name\": \"personal\",\n            \"email\": \"mymail@personal.it\"\n        }\n    ]\n}\n```\n\nyou can reduce it like this selecting the fields `name,email{name},city`:\n\n```go\ngofield.Reduce(fatObj, \"name,email{name},city\")\n```\n\n```json\n{\n    \"name\": \"Enrico\",\n    \"city\": \"Rome\",\n    \"email\":[\n        {\n            \"name\": \"work\"\n        },\n        {\n            \"name\": \"personal\"\n        }\n    ]\n}\n```\n\nYou can obviously nest as many levels as you want!\n\nA sample server can be run on the `:8080` to test it. \n\n```shell\ngo run cmd/gofield-server/main.go\n```\n\nJust send your JSON with a POST on the `/reduce` endpoint, with a query parameter `fields`. :)\n\n```\nPOST /reduce?fields=foo,bar{inner_bar}\n```\n\nNote:  \nperformance were not benchmarked, so do your homework before use it on production!\n\nIssues and PR are welcome!\n\nDeveloped By\n--------\n\nEnrico Candino - www.enricocandino.it\n\n\u003ca href=\"https://twitter.com/enrichmann\"\u003e\n  \u003cimg alt=\"Follow me on Twitter\"\n       src=\"http://icons.iconarchive.com/icons/danleech/simple/96/twitter-icon.png\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://plus.google.com/+EnricoCandino\"\u003e\n  \u003cimg alt=\"Follow me on Google+\"\n       src=\"http://icons.iconarchive.com/icons/danleech/simple/96/google-plus-icon.png\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://it.linkedin.com/in/enrico-candino-78995553\"\u003e\n  \u003cimg alt=\"Follow me on LinkedIn\"\n       src=\"http://icons.iconarchive.com/icons/danleech/simple/96/linkedin-icon.png\" /\u003e\n\u003c/a\u003e\n\n\nLicense\n--------\n\n    The MIT License (MIT)\n    \n    Copyright (c) 2017 Enrico Candino\n    \n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n    \n    The above copyright notice and this permission notice shall be included in all\n    copies or substantial portions of the Software.\n    \n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n    SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenrichman%2Fgofield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenrichman%2Fgofield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenrichman%2Fgofield/lists"}