mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 11:05:44 +08:00
refs #911, utility functions for cut and paste JSON
This commit is contained in:
committed by
Mathew Sutcliffe
parent
6c752b81f5
commit
b785e32256
@@ -126,7 +126,7 @@ namespace BlackCore
|
|||||||
CLogMessage(this).error("Authentication failed, no response from %1") << urlString;
|
CLogMessage(this).error("Authentication failed, no response from %1") << urlString;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!json.startsWith('{') || !json.endsWith('}'))
|
if (!Json::looksLikeJson(json))
|
||||||
{
|
{
|
||||||
CLogMessage(this).error("Illegal JSON object: %1") << CNetworkUtils::removeHtmlPartsFromPhpErrorMessage(json);
|
CLogMessage(this).error("Illegal JSON object: %1") << CNetworkUtils::removeHtmlPartsFromPhpErrorMessage(json);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -449,5 +449,18 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
return currentObject;
|
return currentObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool looksLikeJson(const QString &json)
|
||||||
|
{
|
||||||
|
if (json.isEmpty()) { return false; }
|
||||||
|
const QString t = json.trimmed();
|
||||||
|
return t.startsWith('{') && t.endsWith('}');
|
||||||
|
}
|
||||||
|
|
||||||
|
bool looksLikeSwiftJson(const QString &json)
|
||||||
|
{
|
||||||
|
// further checks would go here
|
||||||
|
return looksLikeJson(json);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -250,6 +250,14 @@ namespace BlackMisc
|
|||||||
//! Merges an incremental json object into an existing one
|
//! Merges an incremental json object into an existing one
|
||||||
BLACKMISC_EXPORT QJsonObject applyIncrementalObject(const QJsonObject &previousObject, const QJsonObject &incrementalObject);
|
BLACKMISC_EXPORT QJsonObject applyIncrementalObject(const QJsonObject &previousObject, const QJsonObject &incrementalObject);
|
||||||
|
|
||||||
|
//! Looks like swift JSON?
|
||||||
|
//! \remark Quick check if the string could be a valid JSON string
|
||||||
|
BLACKMISC_EXPORT bool looksLikeJson(const QString &json);
|
||||||
|
|
||||||
|
//! Looks like swift JSON?
|
||||||
|
//! \remark Quick check if the string could be a valid swift JSON string
|
||||||
|
BLACKMISC_EXPORT bool looksLikeSwiftJson(const QString &json);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Load JSON file and init by that
|
* Load JSON file and init by that
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user