Hello,
I wanna ask about Json in c++.
How can I print Json value in c++,
Let's say that I have this Json :
{
"nameS" : "Jason",
"ageS" : "16"
}
How can I print "He's Jason" or "16 years old".
I already tried these :
void printmyJson(Json::Value ¶ms)
{
....
Json::Value root;
std::string name;
std::string age;
std::string mName;
for(Json::ValueIterator it = params.begin(); it!= params.end(); ++it)
{
mName = it.memberName();
name = root.get(mName,0).asString.c_str();
}
printf("He's %s",name\n);
printf("He is %s",mName);
....
}
But it always output this :
"He's "
"He's name"
So, the
variable name is NULL instead of it's value (Jason). And variable
mName is filled with Json string instead of(which I wanted)it's value (Jason).
Can someone help me on this?
many thanks