commit 8414403e084558a56915429ff7e84d7347870e38
parent 2d220258ee69f772690b3e53e6e63112defe1115
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date: Wed, 7 Mar 2018 13:50:53 +0100
fix object walking.
Diffstat:
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git 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
@@ -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\"}",