JSONElement* JSONArray::find(std::string path) const{ auto item = JSONElement::find(path); if (!item || !*item){ int idx = path.find_first_of(".["); if (idx > 0){ auto key = path.substr(0, idx); if (key.compare("this") == 0){ return (JSONElement*)this; } else if (isPositiveInteger(key)){ JSONElement* elem; auto index = atoi(key.c_str()); elem = get(index); unsigned int nIdx = idx + (path[idx] == '.' ? 1 : 0); if (nIdx < path.length()){ return elem->find(path.substr(nIdx)); } return elem; } } else if (idx == 0 && path[0] == '.'){ return find(path.substr(1)); } else if (idx == 0 && path[0] == '['){ unsigned int eIdx = path.find_first_of(']', 1); if (eIdx > 0){ auto key = path.substr(1, eIdx - 1); if (isPositiveInteger(key)){ auto index = atoi(key.c_str()); auto elem = get(index); if (eIdx + 1 < path.length()){ return elem->find(path.substr(eIdx + 1)); } return elem; } } } else{ if (path.compare("this") == 0){ return (JSONElement*)this; } else{ if (isPositiveInteger(path)){ auto index = atoi(path.c_str()); return get(index); } } } } return item; }