I figured it out, and made a sample code that will go through any JSON file and read the data. It doesn't do anything but at least it shows how the JSON parser works. Here is the code if anyone stumbles uppon this:
void checkJSONfile(const char* filepath);
void checkJSONelement(JSONElement* el);
void checkJSONarray(JSONArray* arr);
void checkJSONobject(JSONObject* obj);
void checkJSONfile(const char* filepath) {
JSONElement* jsonbase = JSONElement::LoadJSONFromFile(filepath);
checkJSONelement(jsonbase);
}
void checkJSONobject(JSONObject* obj) {
int nPairs = obj->m_iNumPairs;
for (int i = 0; i < nPairs; i++) {
JSONKeyPair* pair = obj->m_pPairs[i];
uString name = pair->m_sName;
JSONElement* el = pair->m_pElement;
checkJSONelement(el);
}
}
void checkJSONarray(JSONArray* arr) {
int nElements = arr->m_iNumElements;
for (int i = 0; i < nElements; i++) {
JSONElement* eli = arr->GetElement(i);
checkJSONelement(eli);
}
}
void checkJSONelement(JSONElement* el) {
if (el->GetType() == AGK_JSON_STRING) {
JSONString* elStr = (JSONString*)el;
uString val = elStr->m_sValue;
}
else if (el->GetType() == AGK_JSON_NUMBER) {
JSONNumber* elNumb = (JSONNumber*)el;
float val = elNumb->m_fValue;
}
else if (el->GetType() == AGK_JSON_BOOL) {
JSONBool* elBool = (JSONBool*)el;
bool val = elBool->m_bValue;
}
else if (el->GetType() == AGK_JSON_ARRAY) {
JSONArray* elArr = (JSONArray*)el;
checkJSONarray(elArr);
}
else if (el->GetType() == AGK_JSON_OBJECT) {
checkJSONobject((JSONObject*)el);
}
}
So by calling checkJSONfile("filepath.json"), this will go through all the json data.