diff --git a/common/json.c b/common/json.c index ce68543b9..5f36499dd 100644 --- a/common/json.c +++ b/common/json.c @@ -411,6 +411,11 @@ void json_add_snum(struct json_result *result, const char *fieldname, int value) json_start_member(result, fieldname); result_append_fmt(result, "%d", value); } +void json_add_double(struct json_result *result, const char *fieldname, double value) +{ + json_start_member(result, fieldname); + result_append_fmt(result, "%f", value); +} void json_add_u64(struct json_result *result, const char *fieldname, uint64_t value) diff --git a/common/json.h b/common/json.h index 6fc1cdde3..805a270a5 100644 --- a/common/json.h +++ b/common/json.h @@ -90,6 +90,9 @@ void json_add_literal(struct json_result *result, const char *fieldname, void json_add_snum(struct json_result *result, const char *fieldname, int value); /* '"fieldname" : value' or 'value' if fieldname is NULL */ +void json_add_double(struct json_result *result, const char *fieldname, + double value); +/* '"fieldname" : value' or 'value' if fieldname is NULL */ void json_add_num(struct json_result *result, const char *fieldname, unsigned int value); /* '"fieldname" : value' or 'value' if fieldname is NULL */