10#include <QJsonDocument>
18 QJsonParseError error;
19 auto doc = QJsonDocument::fromJson (json, &error);
20 if (error.error == QJsonParseError::NoError)
27 std::string MakeUnexpectedMessage (QJsonValue::Type expected,
const auto& value)
30 QDebug dbg { &result };
31 dbg <<
"unexpected JSON: expected" << expected <<
"but got" << value;
32 return result.toStdString ();
37 :
std::runtime_error { MakeUnexpectedMessage (expected, value) }
42 :
std::runtime_error { MakeUnexpectedMessage (expected, doc) }
static Either Left(const L &l)
static Either Right(R &&r)
UnexpectedJson(QJsonValue::Type expected, const QJsonValue &)
Either< QString, QJsonDocument > ToJson(const QByteArray &json)