common/json: Implement json_add_snum for signed numbers.

This commit is contained in:
ZmnSCPxj 2018-01-26 23:25:37 +00:00 committed by Christian Decker
parent 1da27c51c2
commit 8c527f3931
2 changed files with 8 additions and 0 deletions

View File

@ -457,6 +457,11 @@ void json_add_num(struct json_result *result, const char *fieldname, unsigned in
json_start_member(result, fieldname);
result_append_fmt(result, "%u", value);
}
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_u64(struct json_result *result, const char *fieldname,
uint64_t value)

View File

@ -89,6 +89,9 @@ void json_add_string(struct json_result *result, const char *fieldname, const ch
void json_add_literal(struct json_result *result, const char *fieldname,
const char *literal, int len);
/* '"fieldname" : value' or 'value' if fieldname is NULL */
void json_add_snum(struct json_result *result, const char *fieldname,
int 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 */