json: routine to create a uint64_t field.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-01-22 06:41:48 +10:30
parent 725512fb03
commit aed857a30c
2 changed files with 11 additions and 0 deletions

View File

@ -6,6 +6,7 @@
#include <ccan/tal/str/str.h>
#include <ccan/tal/tal.h>
#include <errno.h>
#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
@ -357,6 +358,13 @@ void json_add_num(struct json_result *result, const char *fieldname, unsigned in
result_append_fmt(result, "%u", value);
}
void json_add_u64(struct json_result *result, const char *fieldname,
uint64_t value)
{
json_start_member(result, fieldname);
result_append_fmt(result, "%"PRIu64, value);
}
void json_add_literal(struct json_result *result, const char *fieldname,
const char *literal, int len)
{

View File

@ -81,6 +81,9 @@ void json_add_literal(struct json_result *result, const char *fieldname,
/* '"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 */
void json_add_u64(struct json_result *result, const char *fieldname,
uint64_t value);
/* '"fieldname" : true|false' or 'true|false' if fieldname is NULL */
void json_add_bool(struct json_result *result, const char *fieldname,
bool value);