File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
src/app/models/key-models Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 44#include < QJsonObject>
55#include < QJsonValue>
66
7+ #include " app/jsonutils.h"
8+
79StreamKeyModel::StreamKeyModel (
810 QSharedPointer<RedisClient::Connection> connection, QByteArray fullPath,
911 int dbIndex, long long ttl)
@@ -27,7 +29,6 @@ QHash<int, QByteArray> StreamKeyModel::getRoles() {
2729
2830QVariant StreamKeyModel::getData (int rowIndex, int dataRole) {
2931 if (!isRowLoaded (rowIndex)) return QVariant ();
30-
3132 switch (dataRole) {
3233 case Value:
3334 return QJsonDocument::fromVariant (m_rowsCache[rowIndex].second )
@@ -145,7 +146,19 @@ int StreamKeyModel::addLoadedRowsToCache(const QVariantList &rows,
145146 auto valKey = valItem->toByteArray ();
146147 valItem++;
147148
148- mappedVal[valKey] = valItem->toByteArray ();
149+ QByteArray fieldValue = valItem->toByteArray ();
150+
151+ if (JSONUtils::isJSON (fieldValue)) {
152+ auto doc = QJsonDocument::fromJson (fieldValue);
153+
154+ if (doc.isObject () || doc.isArray ()) {
155+ mappedVal[valKey] = doc.toVariant ();
156+ } else {
157+ mappedVal[valKey] = fieldValue;
158+ }
159+ } else {
160+ mappedVal[valKey] = fieldValue;
161+ }
149162 }
150163
151164 value.second = mappedVal;
You can’t perform that action at this time.
0 commit comments