mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
Add Json::parseUntilMalformed helper
Signed-off-by: Dylan Schooner <dschooner05@gmail.com>
This commit is contained in:
parent
43fce3ae46
commit
e1eee6e3ca
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