Reputation: 163
I want something like the below in json c++ code
{
"Numofbooks": 2
"book1": { "title":"saaas", "ISBN":234234, "author":"sdjjh"}
"book2": { "title":"fdfrg", "ISBN":8978, "author":"dttt"}
}
I have already checked this link and it this, but it doesnt show how to do it in C++ code. I am using this JSON CPP library, http://jsoncpp.sourceforge.net.
So to code I should do something like belo
Json::objectvalue obj;
obj[numofbooks] = 2;
Next how do I fill this list of book1 and book2?? I am not getting this..Please advice
Upvotes: 0
Views: 3497
Reputation: 861
Json::Value arr(Json::arrayValue);
arr.append("a");
arr.append("b");
arr.append(1000);
Json::Value obj;
obj["a"] = "aa";
obj["b"] = 1000;
obj["c"] = arr;
std::cout << arr.toStyledString() << std::endl;
std::cout << obj.toStyledString() << std::endl;
Upvotes: 2