Showing the changes to interface/src/scripting/GooglePolyScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -39,12 +39,11 @@ void GooglePolyScriptingInterface::setAPIKey(QString key) { · 38 unmodified lines | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | void GooglePolyScriptingInterface::getAssetList() { | 41 | void GooglePolyScriptingInterface::getAssetList() { |
| 42 | authCode = "AIzaSyDamk7Vth52j7aU9JVKn3ungFS0kGJYc8A"; | ||
| 43 | //authCode = "broke"; | 42 | //authCode = "broke"; |
| 44 | QUrl url(listPolyUrl + "key=" + authCode); | 43 | QUrl url(listPolyUrl + "key=" + authCode); |
| 45 | QByteArray jsonString = getHTTPRequest(url); | 44 | QByteArray jsonString = getHTTPRequest(url); |
| 46 | qCDebug(scriptengine) << "the list: " << jsonString; | 45 | qCDebug(scriptengine) << "the list: " << jsonString; |
| 47 | QJsonObject json = makeJSONObject(&jsonString, true); | 46 | QJsonObject json = makeJSON(&jsonString, true).toJsonObject; |
| 48 | 47 | ||
| 49 | } | 48 | } |
| 50 | 49 | ||
| @@ -60,7 +59,8 @@ QByteArray GooglePolyScriptingInterface::getHTTPRequest(QUrl url) { · 9 unmodified lines | |||
| 60 | 59 | ||
| 61 | } | 60 | } |
| 62 | 61 | ||
| 63 | QJsonObject GooglePolyScriptingInterface::makeJSONObject(QByteArray* response, bool isList) { | 62 | // since the list is a QJsonArray and a single model is a QJsonObject |
| 63 | QVariant GooglePolyScriptingInterface::makeJSON(QByteArray* response, bool isList) { | ||
| 64 | //QString firstItem = QString::fromUtf8(response->readAll()); | 64 | //QString firstItem = QString::fromUtf8(response->readAll()); |
| 65 | QJsonDocument doc = QJsonDocument::fromJson(*response); | 65 | QJsonDocument doc = QJsonDocument::fromJson(*response); |
| 66 | qCDebug(scriptengine) << "json doc is empty: " << doc.isEmpty(); | 66 | qCDebug(scriptengine) << "json doc is empty: " << doc.isEmpty(); |
| @@ -71,8 +71,13 @@ QJsonObject GooglePolyScriptingInterface::makeJSONObject(QByteArray* response, b · 4 unmodified lines | |||
| 71 | qCDebug(scriptengine) << "Invalid API key"; | 71 | qCDebug(scriptengine) << "Invalid API key"; |
| 72 | return obj; | 72 | return obj; |
| 73 | } | 73 | } |
| 74 | qCDebug(scriptengine) << "total size: " << obj.value("totalSize").toString(); | 74 | qCDebug(scriptengine) << "total size: " << obj.value("totalSize"); |
| 75 | qCDebug(scriptengine) << "in assets: " << obj.value("assets"); | 75 | qCDebug(scriptengine) << "the assets: " << obj.value("assets"); |
| 76 | QJsonArray arr = obj.value("assets").toArray(); | ||
| 77 | qCDebug(scriptengine) << "in array: " << arr; | ||
| 78 | QJsonObject first = arr.takeAt(0).toObject(); | ||
| 79 | qCDebug(scriptengine) << "first asset: " << first; | ||
| 80 | qCDebug(scriptengine) << "first asset description: " << first.value("description"); | ||
| 76 | return obj; | 81 | return obj; |
| 77 | } | 82 | } |
| 78 | 83 | ||