How should I proceed to serialize a nested object?
Example:
class B
{
public:
int y;
template<class Archive>
void serialize(Archive& ar)
{
ar(CEREAL_NVP(y));
}
}
class A
{
public:
int x;
std::vector<B> nested;
template<class Archive>
void serialize(Archive& ar)
{
ar(CEREAL_NVP(x) what about nested? )
}
}
The main idea is to have something like
{
"x": ...
"nested": [
{
"y": ...
},
{
"y": ...
}
]
}
By the way, a second question if I may. Can I from a json like this get an A object again? Thank you guys =)