Using rapidjson to handle json. But i need to get array under “kelimeler” branch and then handle jsons inside that array with rapid json. So, how to get the array in cocos2d-x?
Hi. Thank you for your reply. I tried it before, tried again but i keep getting the error:
jni/../../Classes/GameScene.cpp: In member function 'virtual void GameScene::onChatReceived(AppWarp::chat)':
jni/../../Classes/GameScene.cpp:177:36: error: invalid initialization of reference of type 'const cocos2d::Value&' from expression of type 'rapidjson::GenericValue<rapidjson::UTF8<> >'
const Value& a = d["kelimeler"];
^
jni/../../Classes/GameScene.cpp:180:44: error: 'const class cocos2d::Value' has no member named 'Size'
for (rapidjson::SizeType i = 0; i < a.Size(); i++) {
^
jni/../../Classes/GameScene.cpp:181:28: error: no match for 'operator[]' (operand types are 'const cocos2d::Value' and 'rapidjson::SizeType {aka unsigned int}')
const Value& c = a[i];
^
jni/../../Classes/GameScene.cpp:182:26: error: no match for 'operator[]' (operand types are 'const cocos2d::Value' and 'const char [4]')
printf("%s \n",c["key"].GetString());
^
You need to specify which Value you want to use since cocos2d also has a class with that name. rapidjson::Value instead of Value. You could also try using rapidjson::Value in your cpp file instead.
Yes there is, and I already posted a link But here it is again for ease of finding it. The code should compile and work to convert a JSON string into a cocos2d::ValueMap or cocos2d::ValueVector.