33#ifndef _QX_SERIALIZE_QJSON_STD_PAIR_H_
34#define _QX_SERIALIZE_QJSON_STD_PAIR_H_
47#include <QtCore/qjsonvalue.h>
48#include <QtCore/qjsonobject.h>
49#include <QtCore/qjsonarray.h>
58template <
typename T1,
typename T2>
61 static inline QJsonValue
toJson(
const std::pair<T1, T2> & t,
const QString & format)
66 return QJsonValue(arr);
70template <
typename T1,
typename T2>
73 static inline qx_bool fromJson(
const QJsonValue & j, std::pair<T1, T2> & t,
const QString & format)
75 t = std::pair<T1, T2>();
76 if (! j.isArray()) {
return qx_bool(
true); }
77 QJsonArray arr = j.toArray();
78 if (arr.count() != 2) {
return qx_bool(
true); }
81 t = std::make_pair(tmp1, tmp2);
qx::cvt : namespace to provide global functions to convert any kind of objects to/from QString and QV...
qx_bool : boolean type with code and description message when an error occured
qx_bool from_json(const QJsonValue &j, T &t, const QString &format=QString())
QJsonValue to_json(const T &t, const QString &format=QString())
Root namespace for all QxOrm library features.
static qx_bool fromJson(const QJsonValue &j, std::pair< T1, T2 > &t, const QString &format)
static QJsonValue toJson(const std::pair< T1, T2 > &t, const QString &format)