Json: Nested objects serialize/deserialize

Created on 12 Feb 2020  路  1Comment  路  Source: nlohmann/json

Hi ,

I have to write a config file from a node editor with something like this

struct Node
{
int id;
string name;
}

struct Pin
{
int id;
Node* node;
}

struct Link
{
int id;
Pin* start;
Pin* end;
}

struct Config
{
std::vector Nodes;
std::vector Pins;
std::vector Links;
}

How can i serialize the topover object Config ? and deserialize ?
Thanks!

question proposed fix

Most helpful comment

You just have to provide from_json and to_json functions for each type as mentioned in README.

Also relevant: https://github.com/nlohmann/json/issues/1648

>All comments

You just have to provide from_json and to_json functions for each type as mentioned in README.

Also relevant: https://github.com/nlohmann/json/issues/1648

Was this page helpful?
0 / 5 - 0 ratings