Hi everyone,
I am developing an open-source library for serialization, deserialization and validation for C++, similar to Python’s Pydantic or Rust’s serde.
https://github.com/getml/reflect-cpp
To give you a taste:
struct Person {
std::string first_name;
std::string last_name;
int age;
};
const auto homer =
Person{.first_name = "Homer",
.last_name = "Simpson",
.age = 45};
const std::string json_string = rfl::json::write(homer);
auto homer2 = rfl::json::read<Person>(json_string).value();
Which will result in the following JSON string:
{"first_name":"Homer","last_name":"Simpson","age":45}
Way more complex structures are possible, including recursive structs, nested structs, algebraic data types and automatic validation.
If you are interested, check it out. Constructive criticism is very welcome.
Top comments (0)