Read Barry Revzin's blog [https://brevzin.github.io/c++/2024/09/30/annotations/] and it motivated me to update the C++26 Reflection support but with annotions to JSON Link. Code like
struct [[=daw::json::reflectable]] X {
[[=daw::json::rename_json{"member1"}]]
int m1;
[[=daw::json::rename_json{"member2"}]]
int m2;
};
Will (de)serialize to and from
{
"member1": 42,
"member2": 24
}
Code Generation in Rust vs C++26
One of the things I like to do is compare how different languages solve the same problem — especially when they end up having very different approaches. It’s always educational. In this case, a bunch of us have been working hard on trying to get reflection — a really transformative language feature — into C++26. Fundamentally, reflection itself can be divided into two pieces: