HerikLyma / CPPWebFramework

​The C++ Web Framework (CWF) is a MVC web framework, Open Source, under MIT License, using C++ with Qt to be used in the development of web applications.
MIT License
445 stars 119 forks source link

tojson:should qvariant::longlong,not QVariant::Int #29

Closed sunwangme closed 4 years ago

sunwangme commented 4 years ago

QJsonArray SqlQuery::toJson() { QJsonArray array; QString error(lastError().text()); if(!error.trimmed().isEmpty()) { array.push_back(QJsonObject{{"success", false}, {"message", error}}); } else if(isSelect()) { loadColumns(); first(); int total = columns.size(); while(isValid()) { QJsonObject json; for(int i = 0; i < total; ++i) { QVariant var(record().value(i)); if(var.type() == QVariant::Double) json[columns[i]] = var.toDouble(); else if(var.type() == QVariant::Int) json[columns[i]] = var.toInt(); else if(var.type() == QVariant::Bool) json[columns[i]] = var.toBool(); else json[columns[i]] = var.toString(); } array.push_back(json); next(); } first(); } return array; }

HerikLyma commented 4 years ago

Hello my friend.

The problem was solved.

Thank you very much.