| 102 | } |
| 103 | |
| 104 | QJsonDocument parseUntilGarbage(const QByteArray& json, QJsonParseError* error, QString* garbage) |
| 105 | { |
| 106 | auto doc = QJsonDocument::fromJson(json, error); |
| 107 | if (error->error == QJsonParseError::GarbageAtEnd) { |
| 108 | qsizetype offset = error->offset; |
| 109 | QByteArray validJson = json.left(offset); |
| 110 | doc = QJsonDocument::fromJson(validJson, error); |
| 111 | |
| 112 | if (garbage) |
| 113 | *garbage = json.right(json.size() - offset); |
| 114 | } |
| 115 | |
| 116 | return doc; |
| 117 | } |
| 118 | |
| 119 | void writeString(QJsonObject& to, const QString& key, const QString& value) |
| 120 | { |
no test coverage detected