Add Json::parseUntilMalformed helper

Signed-off-by: Dylan Schooner <dschooner05@gmail.com>
(cherry picked from commit e1eee6e3ca)
This commit is contained in:
Dylan Schooner 2025-12-18 13:33:13 -05:00 committed by github-actions[bot]
parent 1ebe081e03
commit 811e3de29b
3 changed files with 16 additions and 8 deletions

View file

@ -169,15 +169,9 @@ bool processZIP(DataPack* pack, ProcessingLevel level)
bool processMCMeta(DataPack* pack, QByteArray&& raw_data)
{
QJsonParseError parse_error;
auto json_doc = QJsonDocument::fromJson(raw_data, &parse_error);
auto json_doc = Json::parseUntilMalformed(raw_data, &parse_error);
if (parse_error.error != QJsonParseError::NoError) {
QByteArray validJson = raw_data.left(parse_error.offset);
json_doc = QJsonDocument::fromJson(validJson, &parse_error);
if (parse_error.error != QJsonParseError::NoError) {
qWarning() << "Failed to parse JSON:" << parse_error.errorString();
return false;
}
qWarning() << "Failed to parse JSON:" << parse_error.errorString();
}
try {