{"id":17914203,"url":"https://github.com/knadh/jsonconfig","last_synced_at":"2025-03-23T23:30:45.839Z","repository":{"id":25922754,"uuid":"29363846","full_name":"knadh/jsonconfig","owner":"knadh","description":"Super tiny JSON configuration file parser with comments support for Go programs","archived":false,"fork":false,"pushed_at":"2016-06-14T06:38:15.000Z","size":4,"stargazers_count":12,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T00:17:59.381Z","etag":null,"topics":[],"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/knadh.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":"2015-01-16T19:20:17.000Z","updated_at":"2024-08-25T21:53:29.000Z","dependencies_parsed_at":"2022-07-24T07:46:06.633Z","dependency_job_id":null,"html_url":"https://github.com/knadh/jsonconfig","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knadh%2Fjsonconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knadh%2Fjsonconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knadh%2Fjsonconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knadh%2Fjsonconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knadh","download_url":"https://codeload.github.com/knadh/jsonconfig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245186438,"owners_count":20574551,"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":[],"created_at":"2024-10-28T19:56:48.934Z","updated_at":"2025-03-23T23:30:45.573Z","avatar_url":"https://github.com/knadh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go jsconfig\n\nKailash Nadh, January 2015\n\nMIT License\n\n## What?\njsconfig is a tiny JSON configuration file parser for Go with support for comments. Really, JSON spec doesn't include comments, but a configuration file without helpful comments is a pain to deal with.\n\nMoreover, JSON for configuration files is powerful when combined with structs, enabling effortless loading of complex, nested data structures with Go's native JSON Unmarshaling.\n\n## Installation (go 1.1+)\n`go get github.com/knadh/jsonconfig`\n\n## Usage\n### Sample file: config.json\nNotice the comments\n\u003cpre\u003e\n{\n\t// url to the site\n\t\"url\": \"http://google.com\",\n\n\t\"methods\": [\"GET\", \"POST\"], // supported methods\n\n\t\"always_load\": true,\n\n\t// nested structure with different types\n\t\"module\": {\n\t\t\"name\": \"Welcome\",\n\t\t\"route\": \"/\",\n\t\t\"port\": 8080\n\t}\n}\n\u003c/pre\u003e\n\n### Loading the configuration\n```go\npackage main\n\nimport (\n\t\"github.com/knadh/jsonconfig\"\n)\n\nfunc main() {\n\t// setup the structure\n\tconfig := struct {\n\t\tUrl string `json:\"url\"`\n\n\t\tMethods []string `json:\"methods\"`\n\n\t\tAlwaysLoad  bool `json:\"always_load\"`\n\n\t\tModule struct{\n\t\t\tName string `json:\"name\"`\n\t\t\tRoute string `json:\"route\"`\n\t\t\tPort int `json:\"port\"`\n\t\t} `json:\"module\"`\n\t}{}\n\n\t// parse and load json config\n\terr := jsonconfig.Load(\"config.json\", \u0026config)\n\n\tif err == nil {\n\t\tprintln(\"The url is\", config.Url)\n\t\tprintln(\"Supported methods are\", config.Methods[0], config.Methods[1])\n\t\t\n\t\tprintln(\"The module is\", config.Module.Name, \"on route\", config.Module.Route)\n\t}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknadh%2Fjsonconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknadh%2Fjsonconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknadh%2Fjsonconfig/lists"}