well I think the question is specific, I want to traverse an array that is in a .json that is of the form:
{ "N" : 5, "Rotacion" : 42, "Igual" : 20, "Inverso" : 0, "RotacionE" : 47, "Espejo" : 22, "Puntuacion" : 0, "_id" : "563b7b4756ab632f47fe6d7f" , "Lados" : [], "Camino" : [ 6, 5, 4, 21, 22, 7, 2, 3, 20, 23, 8, 1, 18, 19, 24, 9, 0, 17, 16, 15, 10, 11, 12, 13, 14 ], "__v" : 0 }
I have searched some tutorials and they tell me to do the following:
const Value& a = document["a"];
assert(a.IsArray());
for (SizeType i = 0; i < a.Size(); i++) // Uses SizeType instead of size_t
printf("a[%d] = %d\n", i, a[i].GetInt());
the problem with this example is that when compiling I get the following error:
/home/jmuniz/code/Cocos2d-x/interface/Classes/HelloWorldScene.cpp:84:7: error: reference to ‘Value’ is ambiguous
const Value& a = d["Camino"];
AND
/home/jmuniz/code/Cocos2d-x/interface/cocos2d/cocos/base/CCValue.h:54:14: note: candidates are: class cocos2d::Value
class CC_DLL Value
^
In file included from /home/jmuniz/code/Cocos2d-x/interface/Classes/HelloWorldScene.cpp:4:0:
/home/jmuniz/Dev/rapidjson-master/include/rapidjson/document.h:1758:31: note: typedef class rapidjson::GenericValue<rapidjson::UTF8<> > rapidjson::Value
typedef GenericValue<UTF8<> > Value;
^
/home/jmuniz/code/Cocos2d-x/interface/Classes/HelloWorldScene.cpp:84:7: error: ‘Value’ does not name a type
const Value& a = d["Camino"];
here I put the piece of code that opens the .json, so you canhave an idea of what I'm doing
FILE* fp = fopen("/home/jmuniz/code/Cocos2d-x/interface/Resources/res/puzzles(copia).json", "r"); // non-Windows use "r"
char readBuffer[65536];
FileReadStream is(fp, readBuffer, sizeof(readBuffer));
Document d;
d.ParseStream(is);
fclose(fp);
please I need to know why the error occurred? or at least tell me how to access the array to print and then manipulate