Working with an API: use objects or QMap/QList?
Hi,
I'm not really new to Qt, because I know it from Python. But I'm a bit new to Qt/C++ so maybe my question is more or less a C++ question.
I'm working on an movie application using the TheMovieDB API and I'm not quite sure, what's the better idea/solution in my case, for example if you call the API to get credits of movie it returns the following JSON (using QJson stuff to parse it):
Code:
"cast": [
{
"id": 819,
"name": "Edward Norton",
"character": "The Narrator",
"order": 0,
"cast_id": 4,
"profile_path": "/588Hrov6wwM9WcU88nJHlw2iufN.jpg"
},
...
So it's an array with different persons and the information you want. Now my question is: what is the best way to represent the data in Qt. One option could be to create a short "cast" object with some get/set and attributes to hold the information. Another way could be to use QMap, in a QList. I'm not sure about what is the better/cleaner solution? Also I want to use the data later in QML, which seems to be a bit difficult/needs more work, to get the data extracted and QML compatible. At the moment I use for that QMap(QString, QVariant) which can be used easy in QML.
Some help would be nice! :)
Thanks in advance.
AlphaX2
Re: Working with an API: use objects or QMap/QList?
If you only need it in the QML based UI it is probably indeed easier to just stick with the QVariantMap.
Otherwise you'll need to create a model, etc.
Cheers,
_