Don't print Warnings for whitespace-only JSON Failures (#2579)

This commit is contained in:
Florian Märkl 2021-01-24 14:12:01 +01:00 committed by GitHub
parent 3c2b263de7
commit 0229e7ed8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -521,6 +521,10 @@ QJsonDocument CutterCore::parseJson(const char *res, const char *cmd)
QJsonDocument doc = QJsonDocument::fromJson(json, &jsonError);
if (jsonError.error != QJsonParseError::NoError) {
// don't call trimmed() before knowing that parsing failed to avoid copying huge jsons all the time
if (json.trimmed().isEmpty()) {
return doc;
}
if (cmd) {
eprintf("Failed to parse JSON for command \"%s\": %s\n", cmd,
jsonError.errorString().toLocal8Bit().constData());