3 ms·
Takes a bunch of manual work per POD, that's the gist of it. Fundamentally, if I have struct { int x = 3; std::string y = "bla"; } I want the json to look lik
by vouwfietsman 2y ago
Takes a bunch of manual work per POD, that's the gist of it.
Fundamentally, if I have struct { int x = 3; std::string y = "bla"; }
I want the json to look like { x: 3, y: "bla" } without writing any code specific to the struct, and have it work bidirectionally. This is currently not possible because of a lot of reasons, but most trivially because the names "x" and "y" do not even exist anymore in your compiled code.
- deleted 2y ago[deleted]
- Tsche 2y agoThis is absolutely possible, even currently - albeit in a very much non-portable way. For example boost::pfr and my own (wip) repr library have the required machinery for this.
- vouwfietsman 2y agoInteresting! There seem to be a lot of limitations though: > Boost.PFR library works with types that satisfy the requirements of SimpleAggregate: aggregate types without base classes, const fields, references, or C arrays: And in general seems to be dependent on C++20 for getting field names. Do you know how this works? Initializer lists seem somehow involved.