aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/json_reclaim.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reclaim/json_reclaim.c')
-rw-r--r--src/reclaim/json_reclaim.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/reclaim/json_reclaim.c b/src/reclaim/json_reclaim.c
index 4eeb22bee..b1ca7a4a5 100644
--- a/src/reclaim/json_reclaim.c
+++ b/src/reclaim/json_reclaim.c
@@ -290,10 +290,11 @@ parse_credential (void *cls, json_t *root, struct GNUNET_JSON_Specification *spe
290{ 290{
291 struct GNUNET_RECLAIM_Credential *cred; 291 struct GNUNET_RECLAIM_Credential *cred;
292 const char *name_str = NULL; 292 const char *name_str = NULL;
293 const char *val_str = NULL;
294 const char *type_str = NULL; 293 const char *type_str = NULL;
295 const char *id_str = NULL; 294 const char *id_str = NULL;
296 char *data; 295 json_t *val_json;
296 char *data = NULL;
297 char *val_str = NULL;
297 int unpack_state; 298 int unpack_state;
298 uint32_t type; 299 uint32_t type;
299 size_t data_size; 300 size_t data_size;
@@ -308,7 +309,7 @@ parse_credential (void *cls, json_t *root, struct GNUNET_JSON_Specification *spe
308 } 309 }
309 // interpret single attribute 310 // interpret single attribute
310 unpack_state = json_unpack (root, 311 unpack_state = json_unpack (root,
311 "{s:s, s?s, s:s, s:s!}", 312 "{s:s, s?s, s:s, s:o!}",
312 "name", 313 "name",
313 &name_str, 314 &name_str,
314 "id", 315 "id",
@@ -316,14 +317,19 @@ parse_credential (void *cls, json_t *root, struct GNUNET_JSON_Specification *spe
316 "type", 317 "type",
317 &type_str, 318 &type_str,
318 "value", 319 "value",
319 &val_str); 320 &val_json);
320 if ((0 != unpack_state) || (NULL == name_str) || (NULL == val_str) || 321 if ((0 != unpack_state) || (NULL == name_str) || (NULL == val_json) ||
321 (NULL == type_str)) 322 (NULL == type_str))
322 { 323 {
323 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 324 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
324 "Error json object has a wrong format!\n"); 325 "Error json object has a wrong format!\n");
325 return GNUNET_SYSERR; 326 return GNUNET_SYSERR;
326 } 327 }
328 if (json_is_string (val_json)) {
329 val_str = GNUNET_strdup (json_string_value (val_json));
330 } else {
331 val_str = json_dumps (val_json, JSON_COMPACT);
332 }
327 type = GNUNET_RECLAIM_credential_typename_to_number (type_str); 333 type = GNUNET_RECLAIM_credential_typename_to_number (type_str);
328 if (GNUNET_SYSERR == 334 if (GNUNET_SYSERR ==
329 (GNUNET_RECLAIM_credential_string_to_value (type, 335 (GNUNET_RECLAIM_credential_string_to_value (type,