changeset 174:59c89b0e9375

Fix regression from old schema changes, regarding assessing whether a JSON response was successful
author Lucas Thompson <dev@lucas.im>
date Tue, 31 Jan 2017 22:47:12 +0000
parents 492970caa62b
children 7532233f8e49
files vamp-json/VampJson.h vamp-server/convert.cpp
diffstat 2 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/vamp-json/VampJson.h	Tue Jan 31 22:21:51 2017 +0000
+++ b/vamp-json/VampJson.h	Tue Jan 31 22:47:12 2017 +0000
@@ -1109,11 +1109,11 @@
 
     static bool
     successful(json11::Json j, std::string &err) {
-        if (!j["success"].is_bool()) {
-            err = "bool expected for success";
+        if (!j["result"].is_object()) {
+            err = "result object expected for success";
             return false;
         }
-        return j["success"].bool_value();
+        return true;
     }
 
     static void
--- a/vamp-server/convert.cpp	Tue Jan 31 22:21:51 2017 +0000
+++ b/vamp-server/convert.cpp	Tue Jan 31 22:47:12 2017 +0000
@@ -295,8 +295,10 @@
     VampJson::BufferSerialisation serialisation =
         VampJson::BufferSerialisation::Array;
 
-    rr.success = j["success"].bool_value();
-    rr.errorText = j["errorText"].string_value();
+    const bool isSuccess = j["result"].is_object();
+    const bool isError = j["error"].is_object();
+    rr.success = isSuccess;
+    rr.errorText = isError ? j["error"]["message"].string_value() : "";
 
     switch (rr.type) {