mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-07-06 13:26:58 +03:00
Add Json::parseUntilMalformed helper
Signed-off-by: Dylan Schooner <dschooner05@gmail.com>
(cherry picked from commit e1eee6e3ca)
This commit is contained in:
parent
1ebe081e03
commit
811e3de29b
3 changed files with 16 additions and 8 deletions
|
|
@ -101,6 +101,17 @@ QJsonArray requireArray(const QJsonDocument& doc, const QString& what)
|
|||
return doc.array();
|
||||
}
|
||||
|
||||
QJsonDocument parseUntilMalformed(const QByteArray& json, QJsonParseError* error)
|
||||
{
|
||||
auto doc = QJsonDocument::fromJson(json, error);
|
||||
if (error->error != QJsonParseError::NoError) {
|
||||
QByteArray validJson = json.left(error->offset);
|
||||
doc = QJsonDocument::fromJson(validJson, error);
|
||||
}
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
void writeString(QJsonObject& to, const QString& key, const QString& value)
|
||||
{
|
||||
if (!value.isEmpty()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue