From 0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 19 Mar 2016 15:23:11 +0100 Subject: first refactoring of JSON logic to address #4150 and #4237 --- src/exchange-lib/exchange_api_json.c | 42 +++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'src/exchange-lib/exchange_api_json.c') diff --git a/src/exchange-lib/exchange_api_json.c b/src/exchange-lib/exchange_api_json.c index d91feba0e..d6c54be5b 100644 --- a/src/exchange-lib/exchange_api_json.c +++ b/src/exchange-lib/exchange_api_json.c @@ -22,6 +22,7 @@ */ #include "platform.h" #include "exchange_api_json.h" +#include "taler_json_lib.h" /** * Navigate and parse data in a JSON tree. @@ -53,24 +54,39 @@ parse_json (json_t *root, GNUNET_assert (0); return i; case MAJ_CMD_AMOUNT: - if (GNUNET_OK != - TALER_json_to_amount (pos, - spec[i].details.amount)) { - GNUNET_break_op (0); - return i; + struct GNUNET_JSON_Specification nspec[] = { + TALER_JSON_spec_amount (NULL, spec[i].details.amount), + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (pos, + nspec, + NULL, NULL)) + { + GNUNET_break_op (0); + return i; + } + break; } - break; case MAJ_CMD_TIME_ABSOLUTE: - if (GNUNET_OK != - TALER_json_to_abs (pos, - spec[i].details.abs_time)) { - GNUNET_break_op (0); - return i; + struct GNUNET_JSON_Specification nspec[] = { + GNUNET_JSON_spec_absolute_time (NULL, spec[i].details.abs_time), + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (pos, + nspec, + NULL, NULL)) + { + GNUNET_break_op (0); + return i; + } + break; } - break; - case MAJ_CMD_STRING: { const char *str; -- cgit v1.2.3