{"id":21940103,"url":"https://github.com/avplayer/static_json","last_synced_at":"2025-04-22T15:23:10.556Z","repository":{"id":151296620,"uuid":"170870166","full_name":"avplayer/static_json","owner":"avplayer","description":"Much much fast, direct and static typed parsing of JSON with C++17","archived":false,"fork":false,"pushed_at":"2020-10-12T17:24:50.000Z","size":1108,"stargazers_count":47,"open_issues_count":0,"forks_count":13,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-29T16:22:40.466Z","etag":null,"topics":["json"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avplayer.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":"2019-02-15T13:34:54.000Z","updated_at":"2024-09-26T06:59:26.000Z","dependencies_parsed_at":"2023-04-14T15:46:49.371Z","dependency_job_id":null,"html_url":"https://github.com/avplayer/static_json","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avplayer%2Fstatic_json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avplayer%2Fstatic_json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avplayer%2Fstatic_json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avplayer%2Fstatic_json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avplayer","download_url":"https://codeload.github.com/avplayer/static_json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250265175,"owners_count":21402048,"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":["json"],"created_at":"2024-11-29T02:28:58.752Z","updated_at":"2025-04-22T15:23:10.519Z","avatar_url":"https://github.com/avplayer.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# c++/json serialization\n\n\n## Introduction\n\nAllows conversion from a C++ structure to json, or from a json to a C++ structure.\n\n## Motivation\n\nIn some of the past projects, json is often used as a protocol, and when dealing with the corresponding protocol, it is often necessary to reference the value object parsed by json in each required place, and then go through the interface provided by the value json library. Access to the fields needed in the business, which leads to the json library-related code everywhere in the code, adding coupling to the json parsing library.\n\nAfter understanding the basic principles of boost.serialization, I designed this library. static_json in the process of serialization and deserialization, the overhead is almost negligible, depending on the efficiency of the rapididjson library.\n\nWith this library, we only need to define the C++ data structure, and then serialize the json data into the structure, so that when accessing, it is no longer through the interface of the json library, but the structure of c++, thus avoiding json library and The degree of coupling of the project.\n\n## How to use\n\nYou can simply include static_json.hpp and rapidjson libraries (rapidjson is also header only), or you can copy the code in the include directory to your own project, and then include it, you can start using it.\n\n\n## Get started quickly\n\n```cpp\n#include \"static_json.hpp\"\n\nint main() {\n\tusing namespace static_json;\n\n\tstd::vector\u003cint\u003e ai = {1, 3, 4, 7, 9};\n\tstd::string a = to_json_string(ai);\n\n\tstd::cout \u003c\u003c a \u003c\u003c std::endl;\n\n\tstd::vector\u003cint\u003e af;\n\tfrom_json_string(af, a);\n}\n```\n\n\n## Invasive c++ structure serialization\n\n```cpp\nstruct proto {\n\tint type;\n\tstd::string name;\n\tdouble height;\n\t\n\ttemplate \u003ctypename Archive\u003e\n\tvoid serialize(Archive \u0026ar)\n\t{\n\t\tar\t\u0026 JSON_SERIALIZATION_NVP(type)\n\t\t\t\u0026 JSON_SERIALIZATION_NVP(name)\n\t\t\t\u0026 JSON_SERIALIZATION_NVP(height);\n\t}\n};\n\n\nproto test1 {1, \"abcd\", 1.83};\nstd::string a = to_json_string(test1);\n\nproto test2;\nfrom_json_string(test2, a); // test2 same as test1.\n```\n\n\n## Non-intrusive c++ structure serialization\n\n\n```cpp\nstruct proto {\n\tint type;\n\tstd::string name;\n\tdouble height;\n};\n\ntemplate\u003cclass Archive\u003e\nvoid serialize(Archive\u0026 ar, proto\u0026 a)\n{\n\tar\t\u0026 JSON_NI_SERIALIZATION_NVP(a, type)\n\t\t\u0026 JSON_NI_SERIALIZATION_NVP(a, name)\n\t\t\u0026 JSON_NI_SERIALIZATION_NVP(a, height);\n}\n\nproto test1 {1, \"abcd\", 1.83};\nstd::string a = to_json_string(test1);\n\nproto test2;\nfrom_json_string(test2, a); // test2 same as test1.\n```\n\n\nFor more usage, see src/main.cpp\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favplayer%2Fstatic_json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favplayer%2Fstatic_json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favplayer%2Fstatic_json/lists"}