| 244 | } |
| 245 | |
| 246 | bool JavaDebugger::parseMainClass(const QString &content, QString &mainClass, QString &projectName) |
| 247 | { |
| 248 | if (content.isEmpty()) |
| 249 | return false; |
| 250 | |
| 251 | QString newContent = "{\"result\":[" + content + "]}"; |
| 252 | //qInfo() << newContent; |
| 253 | |
| 254 | //ex : "{\"result\":[{\"mainClass\":\"com.uniontech.App\",\"projectName\":\"maven_demo\",\"filePath\":\"/App.java\"}]}" |
| 255 | QByteArray data = newContent.toUtf8(); |
| 256 | QJsonParseError parseError; |
| 257 | QJsonDocument doc = QJsonDocument::fromJson(data, &parseError); |
| 258 | if (QJsonParseError::NoError != parseError.error) { |
| 259 | return false; |
| 260 | } |
| 261 | |
| 262 | if (!doc.isObject()) |
| 263 | return false; |
| 264 | |
| 265 | QJsonObject rootObject = doc.object(); |
| 266 | QJsonArray array = rootObject.value("result").toArray(); |
| 267 | foreach (auto value, array) { |
| 268 | QJsonObject object = value.toObject(); |
| 269 | mainClass = object.value("mainClass").toString(); |
| 270 | projectName = object.value("projectName").toString(); |
| 271 | |
| 272 | if (!mainClass.isEmpty() && !projectName.isEmpty()) |
| 273 | return true; |
| 274 | } |
| 275 | |
| 276 | return false; |
| 277 | } |
| 278 | |
| 279 | bool JavaDebugger::parseClassPath(const QString &content, QStringList &classPaths) |
| 280 | { |