diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-03-15 16:44:53 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-03-15 16:44:53 +0100 |
commit | 37a194c0bada3161bd75d765da00d6fb9de3d5f9 (patch) | |
tree | 59aefc1bf599e47c99a3c001bd703218ea858f16 | |
parent | 53b189868edbc855240026c2a02fe6c4e53f9bb0 (diff) |
simplify json construction code
-rw-r--r-- | src/mint/mint_db.c | 3 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_keystate.c | 82 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_responses.c | 4 |
3 files changed, 38 insertions, 51 deletions
diff --git a/src/mint/mint_db.c b/src/mint/mint_db.c index 848f9e045..50904df39 100644 --- a/src/mint/mint_db.c +++ b/src/mint/mint_db.c @@ -1049,7 +1049,8 @@ TALER_MINT_DB_insert_collectable_blindcoin (PGconn *db_conn, GNUNET_CRYPTO_rsa_public_key_encode (collectable->denom_pub, &denom_pub_enc); denom_sig_enc_size = - GNUNET_CRYPTO_rsa_signature_encode (collectable->sig, &denom_sig_enc); + GNUNET_CRYPTO_rsa_signature_encode (collectable->sig, + &denom_sig_enc); struct TALER_DB_QueryParam params[] = { TALER_DB_QUERY_PARAM_PTR (h_blind), TALER_DB_QUERY_PARAM_PTR_SIZED (denom_pub_enc, denom_pub_enc_size - 1), diff --git a/src/mint/taler-mint-httpd_keystate.c b/src/mint/taler-mint-httpd_keystate.c index abc746e7d..4be13a0bb 100644 --- a/src/mint/taler-mint-httpd_keystate.c +++ b/src/mint/taler-mint-httpd_keystate.c @@ -116,38 +116,27 @@ static int reload_pipe[2]; static json_t * denom_key_issue_to_json (const struct TALER_MINT_DenomKeyIssue *dki) { - json_t *dk_json = json_object (); - - json_object_set_new (dk_json, - "master_sig", - TALER_JSON_from_data (&dki->signature, - sizeof (struct GNUNET_CRYPTO_EddsaSignature))); - json_object_set_new (dk_json, - "stamp_start", - TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->start))); - json_object_set_new (dk_json, - "stamp_expire_withdraw", - TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_withdraw))); - json_object_set_new (dk_json, - "stamp_expire_deposit", - TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_spend))); - - json_object_set_new (dk_json, - "denom_pub", - TALER_JSON_from_rsa_public_key (dki->denom_pub)); - json_object_set_new (dk_json, - "value", - TALER_JSON_from_amount (TALER_amount_ntoh (dki->value))); - json_object_set_new (dk_json, - "fee_withdraw", - TALER_JSON_from_amount (TALER_amount_ntoh (dki->fee_withdraw))); - json_object_set_new (dk_json, - "fee_deposit", - TALER_JSON_from_amount (TALER_amount_ntoh (dki->fee_deposit))); - json_object_set_new (dk_json, - "fee_refresh", - TALER_JSON_from_amount (TALER_amount_ntoh (dki->fee_refresh))); - return dk_json; + return + json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}", + "master_sig", + TALER_JSON_from_data (&dki->signature, + sizeof (struct GNUNET_CRYPTO_EddsaSignature)), + "stamp_start", + TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->start)), + "stamp_expire_withdraw", + TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_withdraw)), + "stamp_expire_deposit", + TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_spend)), + "denom_pub", + TALER_JSON_from_rsa_public_key (dki->denom_pub), + "value", + TALER_JSON_from_amount (TALER_amount_ntoh (dki->value)), + "fee_withdraw", + TALER_JSON_from_amount (TALER_amount_ntoh (dki->fee_withdraw)), + "fee_deposit", + TALER_JSON_from_amount (TALER_amount_ntoh (dki->fee_deposit)), + "fee_refresh", + TALER_JSON_from_amount (TALER_amount_ntoh (dki->fee_refresh))); } @@ -160,23 +149,18 @@ denom_key_issue_to_json (const struct TALER_MINT_DenomKeyIssue *dki) static json_t * sign_key_issue_to_json (const struct TALER_MINT_SignKeyIssue *ski) { - json_t *sk_json = json_object (); - - json_object_set_new (sk_json, - "stamp_start", - TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (ski->start))); - json_object_set_new (sk_json, - "stamp_expire", - TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (ski->expire))); - json_object_set_new (sk_json, - "master_sig", - TALER_JSON_from_data (&ski->signature, - sizeof (struct GNUNET_CRYPTO_EddsaSignature))); - json_object_set_new (sk_json, - "key", - TALER_JSON_from_data (&ski->signkey_pub, - sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))); - return sk_json; + return + json_pack ("{s:o, s:o, s:o, s:o}", + "stamp_start", + TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (ski->start)), + "stamp_expire", + TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (ski->expire)), + "master_sig", + TALER_JSON_from_data (&ski->signature, + sizeof (struct GNUNET_CRYPTO_EddsaSignature)), + "key", + TALER_JSON_from_data (&ski->signkey_pub, + sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))); } diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c index 1a0a7c997..3d827b118 100644 --- a/src/mint/taler-mint-httpd_responses.c +++ b/src/mint/taler-mint-httpd_responses.c @@ -689,7 +689,9 @@ TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection, root = json_object (); list = json_array (); - json_object_set_new (root, "ev_sigs", list); + json_object_set_new (root, + "ev_sigs", + list); for (newcoin_index = 0; newcoin_index < num_newcoins; newcoin_index++) json_array_append_new (list, TALER_JSON_from_rsa_signature (sigs[newcoin_index])); |