gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-twister] 10/34: fix object walking.


From: gnunet
Subject: [GNUnet-SVN] [taler-twister] 10/34: fix object walking.
Date: Sat, 17 Mar 2018 01:58:01 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository twister.

commit 8414403e084558a56915429ff7e84d7347870e38
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Mar 7 13:50:53 2018 +0100

    fix object walking.
---
 src/test/test_twister_webserver.c   |  2 +-
 src/twister/taler-twister-service.c | 25 +++++++++++++++++--------
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/test/test_twister_webserver.c 
b/src/test/test_twister_webserver.c
index d34217d..0fdc291 100644
--- a/src/test/test_twister_webserver.c
+++ b/src/test/test_twister_webserver.c
@@ -47,7 +47,7 @@ answer_to_connection
   const char *page = "<html><body>Hello, browser!</body></html>";
   #endif
 
-  const char *page = "{\"hello\": \"browser!\"}";
+  const char *page = "{\"hello\": [{\"this\": \"browser!\"}]}";
 
   struct MHD_Response *response;
   int ret;
diff --git a/src/twister/taler-twister-service.c 
b/src/twister/taler-twister-service.c
index 13a09a2..c2de357 100644
--- a/src/twister/taler-twister-service.c
+++ b/src/twister/taler-twister-service.c
@@ -1105,6 +1105,7 @@ create_response (void *cls,
   {
     json_t *parsed_response;
     json_t *element;
+    json_t *cur;
     json_error_t error;
     char *token_path;
     char *mod_response;
@@ -1144,19 +1145,27 @@ create_response (void *cls,
          a number or not, and react accordingly.  We lazily
          try to get the element until something is found or
          not. */
-      if (NULL != (element = json_object_get (element,
-                                              token_path)))
+      if (NULL != (cur = json_object_get (element,
+                                          token_path)))
+      {
+        element = cur;
         continue;
+      }
+
+      index = (unsigned int) strtoul (token_path,
+                                      NULL,
+                                      10);
 
-      GNUNET_assert (-1 != GNUNET_asprintf (&token_path,
-                                            "%u",
-                                            &index));
-      if (NULL != (element = json_array_get (element,
-                                             index)))
+      if (NULL != (cur = json_array_get (element,
+                                         index)))
+      {
+        element = cur;
         continue;
+      }
 
-      TALER_LOG_ERROR ("Path token '%s' not found",
+      TALER_LOG_ERROR ("Path token '%s' not found\n",
                        token_path);
+
       return create_and_queue_response
         (con,
          "{\"error\": \"path token not found\"}",

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]