{"id":25709175,"url":"https://github.com/chocolacula/easy_reflection_cpp","last_synced_at":"2025-04-06T09:06:53.834Z","repository":{"id":39082508,"uuid":"348034712","full_name":"chocolacula/easy_reflection_cpp","owner":"chocolacula","description":"Reflection brings the best way to serialize/deserialize json and yaml in C++","archived":false,"fork":false,"pushed_at":"2025-02-04T19:27:02.000Z","size":643,"stargazers_count":102,"open_issues_count":13,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-30T08:07:32.372Z","etag":null,"topics":["clang","cpp17","json","reflection","serde","serialization","yaml"],"latest_commit_sha":null,"homepage":"","language":"C++","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/chocolacula.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":"2021-03-15T16:00:21.000Z","updated_at":"2025-03-16T15:33:22.000Z","dependencies_parsed_at":"2023-10-15T14:04:21.671Z","dependency_job_id":"4767cf93-855f-4704-a9a0-9bd323b09aa4","html_url":"https://github.com/chocolacula/easy_reflection_cpp","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chocolacula%2Feasy_reflection_cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chocolacula%2Feasy_reflection_cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chocolacula%2Feasy_reflection_cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chocolacula%2Feasy_reflection_cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chocolacula","download_url":"https://codeload.github.com/chocolacula/easy_reflection_cpp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457799,"owners_count":20941906,"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":["clang","cpp17","json","reflection","serde","serialization","yaml"],"created_at":"2025-02-25T09:22:41.537Z","updated_at":"2025-04-06T09:06:53.816Z","avatar_url":"https://github.com/chocolacula.png","language":"C++","readme":"# Easy Reflection solution for C++\n\n[![CMake build and test](https://github.com/chocolacula/reflection_cpp/actions/workflows/cmake.yml/badge.svg)](https://github.com/chocolacula/reflection_cpp/actions/workflows/cmake.yml)\n\u003ca href=\"https://github.com/fffaraz/awesome-cpp#reflection\"\u003e\u003cimg src=\"https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg\" alt=\"Listed on Awesome C++\"\u003e\u003c/img\u003e\u003c/a\u003e\n\nIt parses C++ source code for special attributes. In the most straightforward situation, you only need to mark an object by `[[er::reflect]]` attribute. All other work will be done by the code generation tool and reflection library.\n\nThe main idea is to use kinda dynamic typing for some type agnostic operations, like copying or getting the name of a type.  \nIt makes it possible to determine a variable type and do the right job - print, serialize/deserialize.\n\nIt's generally a proof of concept, created with the idea that it could be used for many years. If you are curious about the details of how it works, you can find them in [DEV article](https://dev.to/chocolacula/how-to-write-reflection-for-c-4527).  \n\n## Features\n\n- Linux, MacOS and Windows, x86 and ARM support\n- translate enums to string and vice versa\n- invoke methods\n- support of stl containers like `std::vector`, `std::list`, `std::map`, etc.\n- smart pointers support\n- native serialization directly to an object and without third parties for:\n  - **JSON**\n  - **YAML 1.2** even with anchors, but keep in mind that variables behind anchors have to be the same type.\n  - binary with **Variable Length Quantity** to reduce number of bytes\n- debug printing\n- understandable errors\n\n## Quick start\n\nLook at [Installation](readme/installation.md) guide and install the solution.\n\nThen define your object and use `[[er::reflect]]`:\n\n```cpp\nclass [[er::reflect]] Object {\n public:\n  std::string field_str;\n  int field_int;\n\n  std::vector\u003cint\u003e field_vector;\n}\n```\n\nAnd serialize/deserialize it in one shot:\n\n```cpp\n#include \"generated/reflection.h\"\n#include \"er/serialization/json.h\"\n\nusing namespace serialization;\n\n...\nauto str = json::to_string\u003cObject\u003e(obj).unwrap();\nobj = json::from_string\u003cObject\u003e(str).unwrap();\n...\n```\n\nFor more details see [How To Use](readme/how_to_use.md).\n\n## Performance\n\nThe repository includes `benchmarks` folder, feel free to check it on your own hardware.\n\nJSON is faster than [nlohmann json](https://github.com/nlohmann/json). Serialization is the same fast as [rapid json](https://github.com/Tencent/rapidjson), deserialization is a little faster with `simdjson` parser and more than twice slower without.\n\nYAML is blazingly faster than [yaml-cpp](https://github.com/jbeder/yaml-cpp) if I did the benchmark right.\n\n\u003e **Note:** Other libraries do not always convert string-represented values to `int`, `float`, or `bool` and don't create instances of `std::string` until you call something like `.get\u003cint\u003e()`. **Easy Reflection**, on the other hand, provides ready-made objects with all values within.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./benchmarks/performance_chart.png\" alt=\"Core i5 benchmarks\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./benchmarks/memory_chart.png\" alt=\"Memory\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003eThe ratio of the content length in bytes\u003c/p\u003e\n\n## Thanks\n\nJetBrains for Open Source Support\n\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n\u003ca href=\"https://jb.gg/OpenSourceSupport\"\u003e\n  \u003cimg src=\"https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg\" alt=\"JetBrains Logo\" style=\"width:128px;height:128px;\"\u003e\n\u003c/a\u003e\n","funding_links":[],"categories":["Reflection"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchocolacula%2Feasy_reflection_cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchocolacula%2Feasy_reflection_cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchocolacula%2Feasy_reflection_cpp/lists"}