Browse Source

common/json: Implement json_add_snum for signed numbers.

ppa-0.6.1
ZmnSCPxj 7 years ago
committed by Christian Decker
parent
commit
8c527f3931
  1. 5
      common/json.c
  2. 3
      common/json.h

5
common/json.c

@ -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)

3
common/json.h

@ -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 */

Loading…
Cancel
Save