| 70 | return memcmp(data.constData(), &tag, sizeof(QJsonDocument::BinaryFormatTag)) == 0; |
| 71 | } |
| 72 | QJsonDocument requireDocument(const QByteArray &data, const QString &what) |
| 73 | { |
| 74 | if (isBinaryJson(data)) |
| 75 | { |
| 76 | // FIXME: Is this needed? |
| 77 | throw JsonException(what + ": Invalid JSON. Binary JSON unsupported"); |
| 78 | } |
| 79 | else |
| 80 | { |
| 81 | QJsonParseError error; |
| 82 | QJsonDocument doc = QJsonDocument::fromJson(data, &error); |
| 83 | if (error.error != QJsonParseError::NoError) |
| 84 | { |
| 85 | throw JsonException(what + ": Error parsing JSON: " + error.errorString()); |
| 86 | } |
| 87 | return doc; |
| 88 | } |
| 89 | } |
| 90 | QJsonDocument requireDocument(const QString &filename, const QString &what) |
| 91 | { |
| 92 | return requireDocument(FS::read(filename), what); |
no test coverage detected