首頁>Club>
5
回覆列表
  • 1 # 使用者834195712159

    程式碼示例:

    #include <iostream>

    #include <string>

    #include <jsoncpp/json/json.h>

    using namespace std;

    int main()

    {

    string strJsonContent = "{\"role_id\": 1,\"occupation\": \"paladin\",\"camp\": \"alliance\"}";

    int nRoleDd = 0;

    string strOccupation = "";

    string strCamp = "";

    Json::Reader reader;

    Json::Value root;

    if (reader.parse(strJsonContent, root))

    {

    nRoleDd = root["role_id"].asInt();

    strOccupation = root["occupation"].asString();

    strCamp = root["camp"].asString();

    }

    cout << "role_id is: " << nRoleDd << endl;

    cout << "occupation is: " << strOccupation << endl;

    cout << "camp is: " << strCamp << endl;

    return 0;

    }

  • 中秋節和大豐收的關聯?
  • 有關籃球的英語知識?