diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-03-19 15:23:11 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-03-19 15:23:11 +0100 |
commit | 0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6 (patch) | |
tree | 0ed4d6f189ed72287a0e003446c87a2b6db70c1a /src/exchange-lib/exchange_api_json.c | |
parent | d229f78da3b0b7f851d3541f59651b4f600c879d (diff) | |
download | exchange-0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6.tar.xz |
first refactoring of JSON logic to address #4150 and #4237
Diffstat (limited to 'src/exchange-lib/exchange_api_json.c')
-rw-r--r-- | src/exchange-lib/exchange_api_json.c | 42 |
1 files changed, 29 insertions, 13 deletions
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; |