How to deserialize data
values?
{"data":
[{
"Id": 3,
"Name" : "Wind",
"Type" : 2,
"Order" : 1,
"user" : "Mike"
}],
"free" : 0,
"line" : 10,
"count" : 1
}
Here's what I've tried so far:
class Class {
public:
virtual ~Class(void);
virtual void Serialize(Json::Value& root);
virtual void Deserialize(Json::Value& root);
int Id;
std::string free;
std::string line;
std::string count;
std::vector<std::string> ID;
};
void Class::Serialize(Json::Value& root) {
// ...
}
void Class::Deserialize(Json::Value& root) {
free = root.get("top", 0).asInt();
line = root.get("skip", 0).asInt();
count = root.get("count", 0).asInt();
Json::Value Data= root["data"];
Id = Data.get("Id", 0).asInt();
}
I cannot deserialize the Data element Id
, etc. The elements free
, line
and count
can be extracted.
I have tried to create a second class to separate them, but that would not work either.