rapidjson::Document d;
d.Parse<0>(chatevent.chat.c_str());
if(d.HasMember("kelimeler"))
{
rapidjson::Value::MemberIterator M;
const char *key,*value;
for (M=d.MemberBegin(); M!=d.MemberEnd(); M++)
{
key = M->name.GetString();
value = M->value.GetString();
if (key!=NULL && value!=NULL)
{
log("key: %s, value: %s", key,value);
}
}
}
這是我用來處理cocos2d-x中的json數據的代碼。而這裏是json:rapidjson cocos2d-x解析
{
"kelimeler": [{
"harfsayisi": 10,
"kelime": "bibnştvdaf",
"harfler": ["t", "s", "ç", "p", "b", "c", "h", "n", "c", "c", "n", "b", "t", "v", "ş", "v", "a", "c", "v", "p", "d", "ğ", "s", "k", "i", "ç", "f", "v", "b", "p", "a", "ü", "d", "ü", "e"]
}]
}
那麼如何使用代碼來處理它呢?我根本無法得到「kelimeler」分支。提前致謝。
不幸的是它不適用於我。我之前嘗試過。 ^ – gokturk
它給你帶來錯誤或錯誤的輸出。指定發生錯誤時的運行時間還是編譯時間錯誤 –