qBittorrent
anonymous_namespace{rss_autodownloader.cpp} Namespace Reference

Functions

QVector< RSS::AutoDownloadRulerulesFromJSON (const QByteArray &jsonData)
 

Function Documentation

◆ rulesFromJSON()

QVector<RSS::AutoDownloadRule> anonymous_namespace{rss_autodownloader.cpp}::rulesFromJSON ( const QByteArray &  jsonData)

Definition at line 66 of file rss_autodownloader.cpp.

67  {
68  QJsonParseError jsonError;
69  const QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData, &jsonError);
70  if (jsonError.error != QJsonParseError::NoError)
71  throw RSS::ParsingError(jsonError.errorString());
72 
73  if (!jsonDoc.isObject())
74  throw RSS::ParsingError(RSS::AutoDownloader::tr("Invalid data format."));
75 
76  const QJsonObject jsonObj {jsonDoc.object()};
77  QVector<RSS::AutoDownloadRule> rules;
78  for (auto it = jsonObj.begin(); it != jsonObj.end(); ++it)
79  {
80  const QJsonValue jsonVal {it.value()};
81  if (!jsonVal.isObject())
82  throw RSS::ParsingError(RSS::AutoDownloader::tr("Invalid data format."));
83 
84  rules.append(RSS::AutoDownloadRule::fromJsonObject(jsonVal.toObject(), it.key()));
85  }
86 
87  return rules;
88  }
static AutoDownloadRule fromJsonObject(const QJsonObject &jsonObj, const QString &name="")

References RSS::AutoDownloadRule::fromJsonObject().

Referenced by RSS::AutoDownloader::importRulesFromJSONFormat(), and RSS::AutoDownloader::loadRules().

Here is the call graph for this function:
Here is the caller graph for this function: