diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2015-09-15 09:05:18 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2015-09-15 09:05:18 +0000 |
commit | 120fbd80a09ff7b4b934572c5ee295bf75b7046b (patch) | |
tree | 6f13a8a88d255c1bfb5e5d01b12f7c475bd8e57f /src/rest | |
parent | 171cfeb1b32e21d12a1dbcbc5a9099bab37fab7e (diff) | |
download | gnunet-120fbd80a09ff7b4b934572c5ee295bf75b7046b.tar.gz gnunet-120fbd80a09ff7b4b934572c5ee295bf75b7046b.zip |
- fixes
Diffstat (limited to 'src/rest')
-rw-r--r-- | src/rest/rest.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/src/rest/rest.c b/src/rest/rest.c index 77427ef6c..95a5d0605 100644 --- a/src/rest/rest.c +++ b/src/rest/rest.c | |||
@@ -407,26 +407,17 @@ GNUNET_REST_jsonapi_data_serialize (const struct JsonApiObject *resp, | |||
407 | return GNUNET_SYSERR; | 407 | return GNUNET_SYSERR; |
408 | 408 | ||
409 | root_json = json_object (); | 409 | root_json = json_object (); |
410 | if (0 == resp->res_count) | 410 | res_arr = json_array (); |
411 | { | 411 | for (res = resp->res_list_head; |
412 | json_object_set (root_json, GNUNET_REST_JSONAPI_KEY_DATA, json_array()); | 412 | res != NULL; |
413 | } | 413 | res = res->next) |
414 | else if (1 == resp->res_count) | ||
415 | { | ||
416 | json_object_set (root_json, GNUNET_REST_JSONAPI_KEY_DATA, resp->res_list_head->res_obj); | ||
417 | } | ||
418 | else | ||
419 | { | 414 | { |
420 | res_arr = json_array (); | 415 | json_array_append (res_arr, res->res_obj); |
421 | for (res = resp->res_list_head; | ||
422 | res != NULL; | ||
423 | res = res->next) | ||
424 | { | ||
425 | json_array_append (res_arr, res->res_obj); | ||
426 | } | ||
427 | json_object_set (root_json, GNUNET_REST_JSONAPI_KEY_DATA, res_arr); | ||
428 | } | 416 | } |
417 | json_object_set (root_json, GNUNET_REST_JSONAPI_KEY_DATA, res_arr); | ||
429 | *result = json_dumps (root_json, JSON_INDENT(2)); | 418 | *result = json_dumps (root_json, JSON_INDENT(2)); |
419 | json_decref (root_json); | ||
420 | json_decref (res_arr); | ||
430 | return GNUNET_OK; | 421 | return GNUNET_OK; |
431 | } | 422 | } |
432 | 423 | ||
@@ -434,13 +425,13 @@ GNUNET_REST_jsonapi_data_serialize (const struct JsonApiObject *resp, | |||
434 | * REST Utilities | 425 | * REST Utilities |
435 | */ | 426 | */ |
436 | 427 | ||
437 | /** | 428 | /** |
438 | * Check if namespace is in URL. | 429 | * Check if namespace is in URL. |
439 | * | 430 | * |
440 | * @param url URL to check | 431 | * @param url URL to check |
441 | * @param namespace namespace to check against | 432 | * @param namespace namespace to check against |
442 | * @retun GNUNET_YES if namespace matches | 433 | * @retun GNUNET_YES if namespace matches |
443 | */ | 434 | */ |
444 | int | 435 | int |
445 | GNUNET_REST_namespace_match (const char *url, const char *namespace) | 436 | GNUNET_REST_namespace_match (const char *url, const char *namespace) |
446 | { | 437 | { |