{"id":19263820,"url":"https://github.com/yinqiwen/kcfg","last_synced_at":"2025-04-21T18:31:48.435Z","repository":{"id":147192910,"uuid":"114233712","full_name":"yinqiwen/kcfg","owner":"yinqiwen","description":"A simple c++ json class/struct mapping head-only library.","archived":false,"fork":false,"pushed_at":"2024-06-13T07:57:21.000Z","size":174,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-01T15:13:01.030Z","etag":null,"topics":["config","cpp","json","mapping"],"latest_commit_sha":null,"homepage":"","language":"C++","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/yinqiwen.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-14T10:00:21.000Z","updated_at":"2024-06-13T07:57:24.000Z","dependencies_parsed_at":"2024-06-13T07:20:31.130Z","dependency_job_id":"4ac04279-d0cf-4c96-b48b-40e00b3adee0","html_url":"https://github.com/yinqiwen/kcfg","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/yinqiwen%2Fkcfg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yinqiwen%2Fkcfg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yinqiwen%2Fkcfg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yinqiwen%2Fkcfg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yinqiwen","download_url":"https://codeload.github.com/yinqiwen/kcfg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250111033,"owners_count":21376573,"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":["config","cpp","json","mapping"],"created_at":"2024-11-09T19:37:01.446Z","updated_at":"2025-04-21T18:31:48.022Z","avatar_url":"https://github.com/yinqiwen.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"kcfg\n======\n\nA head-only C++ json/toml/yaml config mapping library. \n\n## Dependency\n\n- [rapidjson](https://github.com/Tencent/rapidjson)\n- [toml](https://github.com/ToruNiina/toml11)\n- [yaml](https://github.com/jbeder/yaml-cpp)\n\n## Limit\n- C++17\n- Max 256 fields in a struct/class\n\n## Example\n\n```cpp\n#include \"kcfg_json.h\"\n#include \"kcfg_toml.h\"\n#include \"kcfg_yaml.h\"\n\nstruct ConfigItem\n{\n        int v0;\n        int y0;\n        KCFG_DEFINE_FIELDS(v0, y0);\n\n        KCFG_YAML_DEFINE_FIELDS(v0, y0);\n\n        KCFG_TOML_DEFINE_FIELDS(v0, y0);\n};\n\nstruct Config\n{\n        int64_t x;\n        int y;\n        float z;\n        std::string aa;\n        std::map\u003cstd::string, int\u003e m1;\n        std::vector\u003cstd::string\u003e v2;\n        std::vector\u003cConfigItem\u003e v3;\n\n        KCFG_DEFINE_FIELDS(x, y, z, aa, m1, v2, v3);\n\n        KCFG_YAML_DEFINE_FIELDS(x, y, z, aa, m1, v2, v3);\n\n        KCFG_TOML_DEFINE_FIELDS(x, y, z, aa, m1, v2, v3);\n\n        Config()\n                : x(0), y(0), z(0)\n        {\n        }\n};\n\n\nint main(int argc, char *argv[])\n{\n\n    std::string json = \"{\\\"x\\\":1, \\\"y\\\":101, \\\"z\\\":2.1, \\\"aa\\\":\\\"val\\\", \\\"m1\\\":{\\\"k1\\\":102}, \\\"v2\\\":[\\\"v0\\\"]}\";\n\n    Config cfg;\n    kcfg::ParseFromJsonString(json, cfg);\n    // kcfg::ParseFromTomlString(content, t);\n    // kcfg::ParseFromYamlString(content, t);\n\n    cfg.v2.push_back(\"testa\");\n    cfg.v2.push_back(\"testv\");\n    cfg.v3.resize(2);\n    cfg.v3[0].v0 = 101;\n    cfg.v3[1].y0 = 987;\n    std::string kstr;\n    kcfg::WriteToJsonString(cfg, kstr);\n    printf(\"%s\\n\",kstr.c_str());\n\n    return 0;\n}\n```\n\n## Embedding kcfg\n\nJust copy all headers into your project. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyinqiwen%2Fkcfg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyinqiwen%2Fkcfg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyinqiwen%2Fkcfg/lists"}