10#include <QJsonDocument>
20 return QJsonDocument::fromVariant (var)
21 .toJson (compact ? QJsonDocument::Compact : QJsonDocument::Indented);
28 QFile file { filename };
29 if (!file.open (QIODevice::WriteOnly))
31 qWarning () << Q_FUNC_INFO
32 <<
"unable to open file"
35 << file.errorString ();
41 qWarning () << Q_FUNC_INFO
42 <<
"unable to write to file"
45 << file.errorString ();
static Either Left(const L &l)
static Either Right(R &&r)
SerializeResult_t SerializeJsonToFile(const QString &filename, const QVariant &var, bool compact)
QByteArray SerializeJson(const QVariant &var, bool compact)
Serializes the given var to JSON representation.