mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-21 08:09:35 +08:00
Minor refactoring for json parser
This commit is contained in:
parent
9d275d6d34
commit
66b982ad03
@ -115,10 +115,10 @@ QVariantMap json::fromJson(const QString& json) {
|
|||||||
|
|
||||||
foreach (const QString &couple, couples) {
|
foreach (const QString &couple, couples) {
|
||||||
QStringList parts;
|
QStringList parts;
|
||||||
qint32 jsonSep = couple.indexOf(":");
|
int jsonSep = couple.indexOf(":");
|
||||||
parts << couple.mid(0, jsonSep);
|
parts << couple.left(jsonSep);
|
||||||
parts << couple.mid(jsonSep + 1);
|
parts << couple.mid(jsonSep + 1);
|
||||||
if (parts.size() != 2) continue;
|
Q_ASSERT(parts.size() == 2);
|
||||||
QString key = parts.first();
|
QString key = parts.first();
|
||||||
if (key.startsWith("\"") && key.endsWith("\"")) {
|
if (key.startsWith("\"") && key.endsWith("\"")) {
|
||||||
key = key.mid(1, key.length()-2);
|
key = key.mid(1, key.length()-2);
|
||||||
@ -133,9 +133,9 @@ QVariantMap json::fromJson(const QString& json) {
|
|||||||
if (list_val.startsWith("\"") && list_val.endsWith("\"")) {
|
if (list_val.startsWith("\"") && list_val.endsWith("\"")) {
|
||||||
varlist << list_val.mid(1, list_val.length()-2).replace("\\n", "\n");
|
varlist << list_val.mid(1, list_val.length()-2).replace("\\n", "\n");
|
||||||
} else {
|
} else {
|
||||||
if (list_val.compare(("false"), Qt::CaseInsensitive) == 0)
|
if (list_val.compare("false", Qt::CaseInsensitive) == 0)
|
||||||
varlist << false;
|
varlist << false;
|
||||||
else if (list_val.compare(("true"), Qt::CaseInsensitive) == 0)
|
else if (list_val.compare("true", Qt::CaseInsensitive) == 0)
|
||||||
varlist << true;
|
varlist << true;
|
||||||
else
|
else
|
||||||
varlist << list_val.toInt();
|
varlist << list_val.toInt();
|
||||||
|
Loading…
Reference in New Issue
Block a user