Browse Source

json: Add utility to add a null-member

Signed-off-by: Christian Decker <decker.christian@gmail.com>
connected_hook
Christian Decker 6 years ago
parent
commit
32713b4379
No known key found for this signature in database GPG Key ID: 1416D83DC4F0E86D
  1. 5
      lightningd/json.c
  2. 4
      lightningd/json.h
  3. 3
      lightningd/test/run-invoice-select-inchan.c
  4. 3
      wallet/test/run-wallet.c

5
lightningd/json.c

@ -299,6 +299,11 @@ void json_add_bool(struct json_stream *result, const char *fieldname, bool value
json_add_member(result, fieldname, value ? "true" : "false"); json_add_member(result, fieldname, value ? "true" : "false");
} }
void json_add_null(struct json_stream *stream, const char *fieldname)
{
json_add_member(stream, fieldname, "null");
}
void json_add_hex(struct json_stream *result, const char *fieldname, void json_add_hex(struct json_stream *result, const char *fieldname,
const void *data, size_t len) const void *data, size_t len)
{ {

4
lightningd/json.h

@ -115,6 +115,10 @@ void json_add_u64(struct json_stream *result, const char *fieldname,
/* '"fieldname" : true|false' or 'true|false' if fieldname is NULL */ /* '"fieldname" : true|false' or 'true|false' if fieldname is NULL */
void json_add_bool(struct json_stream *result, const char *fieldname, void json_add_bool(struct json_stream *result, const char *fieldname,
bool value); bool value);
/* '"fieldname" : null' or 'null' if fieldname is NULL */
void json_add_null(struct json_stream *stream, const char *fieldname);
/* '"fieldname" : "0189abcdef..."' or "0189abcdef..." if fieldname is NULL */ /* '"fieldname" : "0189abcdef..."' or "0189abcdef..." if fieldname is NULL */
void json_add_hex(struct json_stream *result, const char *fieldname, void json_add_hex(struct json_stream *result, const char *fieldname,
const void *data, size_t len); const void *data, size_t len);

3
lightningd/test/run-invoice-select-inchan.c

@ -142,6 +142,9 @@ void json_add_hex_talarr(struct json_stream *result UNNEEDED,
void json_add_log(struct json_stream *result UNNEEDED, void json_add_log(struct json_stream *result UNNEEDED,
const struct log_book *lr UNNEEDED, enum log_level minlevel UNNEEDED) const struct log_book *lr UNNEEDED, enum log_level minlevel UNNEEDED)
{ fprintf(stderr, "json_add_log called!\n"); abort(); } { fprintf(stderr, "json_add_log called!\n"); abort(); }
/* Generated stub for json_add_null */
void json_add_null(struct json_stream *stream UNNEEDED, const char *fieldname UNNEEDED)
{ fprintf(stderr, "json_add_null called!\n"); abort(); }
/* Generated stub for json_add_num */ /* Generated stub for json_add_num */
void json_add_num(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED, void json_add_num(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
unsigned int value UNNEEDED) unsigned int value UNNEEDED)

3
wallet/test/run-wallet.c

@ -215,6 +215,9 @@ void json_add_hex_talarr(struct json_stream *result UNNEEDED,
void json_add_log(struct json_stream *result UNNEEDED, void json_add_log(struct json_stream *result UNNEEDED,
const struct log_book *lr UNNEEDED, enum log_level minlevel UNNEEDED) const struct log_book *lr UNNEEDED, enum log_level minlevel UNNEEDED)
{ fprintf(stderr, "json_add_log called!\n"); abort(); } { fprintf(stderr, "json_add_log called!\n"); abort(); }
/* Generated stub for json_add_null */
void json_add_null(struct json_stream *stream UNNEEDED, const char *fieldname UNNEEDED)
{ fprintf(stderr, "json_add_null called!\n"); abort(); }
/* Generated stub for json_add_num */ /* Generated stub for json_add_num */
void json_add_num(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED, void json_add_num(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
unsigned int value UNNEEDED) unsigned int value UNNEEDED)

Loading…
Cancel
Save