A suggestion to QJson related classes...
-
Typically I write the following to retrieve data from a json document:
data["query"].toObject()["test"].toArray()[1]
This is great, but is quite "textful". I believe the following will be better code:
data["query"]["test"][1]
which removes all the type conversion part.
And I believe this is possible with the current settings. Because we have methods like isArray, isObject etc, the framework actually knows the internal type of the QJsonValue, so we can return the value accordingly, like:
QJsonValue QJsonValue::operator[](int i)
{
if (this->isArray())
return this->toArray()[i];
}QJsonValue QJsonValue::operator[](QString s)
{
if (this->isObject())
return this->toObject()[s];
}And this will simplify the written code quite a lot!
Any suggestions?
-
I'm not using QJson*, so I don't feel strongly either way. Your proposal looks very much like 2D array, which might be confusing.
In any case, Qt developers rarely visit this forum (save for several exception). If you want to be heard by people who make Qt happen, write to "Development Mailing List":http://lists.qt-project.org/mailman/listinfo.