{"id":25238601,"url":"https://github.com/pchchv/sfj","last_synced_at":"2026-05-02T19:31:46.060Z","repository":{"id":276663359,"uuid":"929907278","full_name":"pchchv/sfj","owner":"pchchv","description":"Generator of Go structs from JSON server responses.","archived":false,"fork":false,"pushed_at":"2025-02-09T18:59:24.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T19:35:59.308Z","etag":null,"topics":["go","go-lib","go-library","go-package","golang","golang-library","golang-package","json","response","structs","structures"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/pchchv/sfj","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pchchv.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-09T17:16:24.000Z","updated_at":"2025-02-09T19:00:25.000Z","dependencies_parsed_at":"2025-02-09T18:38:31.021Z","dependency_job_id":null,"html_url":"https://github.com/pchchv/sfj","commit_stats":null,"previous_names":["pchchv/sfj"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/pchchv/sfj","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchchv%2Fsfj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchchv%2Fsfj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchchv%2Fsfj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchchv%2Fsfj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pchchv","download_url":"https://codeload.github.com/pchchv/sfj/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchchv%2Fsfj/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32547645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T19:18:06.202Z","status":"ssl_error","status_checked_at":"2026-05-02T19:16:21.335Z","response_time":132,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","go-lib","go-library","go-package","golang","golang-library","golang-package","json","response","structs","structures"],"created_at":"2025-02-11T17:52:22.159Z","updated_at":"2026-05-02T19:31:46.043Z","avatar_url":"https://github.com/pchchv.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SFJ [![GoDoc](https://godoc.org/github.com/pchchv/sfj?status.svg)](https://godoc.org/github.com/pchchv/sfj)\n\n### Struct from JSON\n\nGenerator of Go structs from JSON server responses.\n\nSFJ defines type names by using the specified lines in the route file and skipping numbers.\ni. e. a request to a route like `/users/1/posts` generates `type UsersPosts`.\n\nSFJ supports *parameters*: a string like `/users/:user/posts/:pid 1 200` generates `type UsersUserPostsPid` from the response to the request `GET /users/1/posts/200`.\n\nSFJ also supports headers personalization, so it can be used to generate types from responses protected by some authorization method.\n\n### Install\n\n`go get -u github.com/pchchv/sfj`\n\n### Usage\n\n```\nsfj [options]\n  -headers string\n    \tHeaders to add in every request\n  -help\n    \tprints this help\n  -insecure\n    \tDisables TLS Certificate check for HTTPS, use in case HTTPS Server Certificate is signed by an unknown authority\n  -out string\n    \tOutput file. Stdout is used if not specified\n  -pkg string\n    \tPackage name (default \"main\")\n  -routes string\n    \tRoutes to request. One per line (default \"routes.txt\")\n  -server string\n    \tsets the server address (default \"http://localhost:9090\")\n  -substruct\n    \tCreates types for sub-structs\n```\n\n### Examples\n\nYou can invoke `sfj` by passing a single JSON (anonymous) from stdin and get it converted to a go structure.\n\n```\necho '  {\n    \"Book Id\": 30558257,\n    \"Title\": \"Unsouled (Cradle, #1)\",\n    \"Author\": \"Will Wight\",\n    \"Author l-f\": \"Wight, Will\",\n    \"Additional Authors\": \"\",\n    \"BCID\": \"\"\n  }' | ./sfj\n```\n\n#### obtaining\n\n```go\npackage main\n\ntype Foo1 struct {\n        Additional_Authors string `json:\"Additional Authors\"`\n        Author             string `json:\"Author\"`\n        Author_l_f         string `json:\"Author l-f\"`\n        Bcid               string `json:\"BCID\"`\n        Book_Id            int64  `json:\"Book Id\"`\n        Title              string `json:\"Title\"`\n}\n```\n\nOr you can set up a more complex scenario by defining a `routes.txt` file with a line for each (parametric) request, and use it as shown below.\n\n*routes.txt*:\n\n```txt\n/\n/repos/:user/:repo pchchv sfj\n```\n\nRun:\n\n```sh\nsfj -server https://api.github.com -pkg example\n```\n\n#### [Returns](./expected_out.txt)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpchchv%2Fsfj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpchchv%2Fsfj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpchchv%2Fsfj/lists"}