Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get nested JSON Values using Rapidjson in C++

In the below example, how to take the name and balance?

{
    "user": {
        "Name": "John",
        "Balance": "2000.53"
    }
}
like image 400
Karthi Avatar asked Dec 10 '22 22:12

Karthi


1 Answers

Easy.

rapidjson::Document doc;
doc.Parse(str);
const Value& user = doc["user"];
string name = user["Name"].GetString();
string balance = user["Balance"].GetString();
like image 119
SashaM Avatar answered Dec 29 '22 23:12

SashaM