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