QJsonDocument: Avoid QJsonObject and QJsonArray in interface#24
QJsonDocument: Avoid QJsonObject and QJsonArray in interface#24lennartS-7cs wants to merge 2 commits intosupamii:QTTPv1.0.0from
Conversation
Previously QJsonObject was used to pass response data. That made it impossible to pass an array as data to the client. To allow both single objects and whole lists of objects, QJsonDocument is now used, which is capable of containing both an object and an array. Signed-off-by: Lennart Sauerbeck <lennart.sauerbeck@sevencs.com>
|
Thanks for the pull request! |
| } | ||
|
|
||
| void HttpData::setResponse(const QJsonObject& json) | ||
| void HttpData::setResponse(const QJsonDocument& json) |
There was a problem hiding this comment.
I went ahead and tried against Qt 5.7 and this will throw up.
/Users/dev/personal/qttpPR/test/qttptest/qttptest.h:23: error: non-const lvalue reference to type 'QJsonObject' cannot bind to a value of unrelated type 'QJsonDocument' QJsonObject& json = data.getResponse().getJson(); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As a compromise, perhaps a MACRO can toggle between the types - however the cascading problem here will be that the object assignments will also be affected.
I am installing 5.9 now and I assume it'll run without a hitch.
Did I do something wrong? Your thoughts on how to proceed?
There was a problem hiding this comment.
So looks like we need to update test files :)
There was a problem hiding this comment.
Ah, sorry. I had trouble getting my local Qt version with MSVC17 to work in QtCreator. That is why I didn't build the tests.
I'll take a look at them right away.
Signed-off-by: Lennart Sauerbeck <lennart.sauerbeck@sevencs.com>
|
After 41a896a the tests build again but four of them fail as they did before my changes. Please allow me to squash the two commits into one before accepting the pull request once you're okay with my changes. |
|
Oh, and before I forget: I made this change while working for my employer. Do you need anything (besides the Signed-Off-By clause) to be okay with corporate changes into your code? We're prepared to send you an e-mail from my manager which wuold grant me the right to publish this change under the MIT license. |
Previously QJsonObject was used to pass response data. That made it
impossible to pass an array as data to the client. To allow both
single objects and whole lists of objects, QJsonDocument is now used,
which is capable of containing both an object and an array.
Signed-off-by: Lennart Sauerbeck lennart.sauerbeck@sevencs.com