bool GameJoltAPI::ParseOutputString( CStdString inputString, vector<map<CStdString, CStdString>> &returnData ) { map<CStdString, CStdString> resourceData; vector<CStdString> parsedLines; vector<CStdString>::iterator it; CStdString curPiece; CStdString curKey; CStdString curValue; int curPos = 0; curPiece = inputString.Tokenize( _T("\n"), curPos ); while ( curPiece != _T("") ) { parsedLines.push_back( curPiece ); curPiece = inputString.Tokenize( _T("\n"), curPos ); } if ( parsedLines.size() == 0 ) { m_ErrorMessage += _T("(Could not parse the response.)"); return false; } for ( it = parsedLines.begin(); it < parsedLines.end(); it++ ) { curPos = (*it).FindOneOf( _T(":") ); curKey = (*it).Mid( 0, curPos ); curValue = (*it).Mid( curPos + 2, (*it).GetLength() - curPos - 4 ); // If this key is set, then we have looped and have a new resource. // Push the data and clear. if ( resourceData[curKey] != _T("") ) { returnData.push_back( resourceData ); resourceData.clear(); } resourceData[curKey] = curValue; } // We do one final push. returnData.push_back( resourceData ); if ( returnData.front()["success"] != _T("true") ) m_ErrorMessage += _T("(") + returnData.front()["message"] + _T(")"); // Return it. return true; }