Skip to content

Commit

Permalink
jsonrpcs: use json null value for c null char* or str*
Browse files Browse the repository at this point in the history
(cherry picked from commit c48e409)
(cherry picked from commit 3632d39)
  • Loading branch information
miconda committed Mar 29, 2021
1 parent 5568945 commit 856c563
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/modules/jsonrpcs/jsonrpcs_mod.c
Expand Up @@ -472,6 +472,7 @@ static srjson_t* jsonrpc_print_value(jsonrpc_ctx_t* ctx, char fmt, va_list* ap)
time_t dt;
struct tm* t;
str *sp;
char *cp;

switch(fmt) {
case 'd':
Expand All @@ -497,11 +498,20 @@ static srjson_t* jsonrpc_print_value(jsonrpc_ctx_t* ctx, char fmt, va_list* ap)
nj = srjson_CreateString(ctx->jrpl, buf);
break;
case 's':
nj = srjson_CreateString(ctx->jrpl, va_arg(*ap, char*));
cp = va_arg(*ap, char*);
if(cp!=NULL) {
nj = srjson_CreateString(ctx->jrpl, cp);
} else {
nj = srjson_CreateNull(ctx->jrpl);
}
break;
case 'S':
sp = va_arg(*ap, str*);
nj = srjson_CreateStr(ctx->jrpl, sp->s, sp->len);
if(sp!=NULL && sp->s!=NULL) {
nj = srjson_CreateStr(ctx->jrpl, sp->s, sp->len);
} else {
nj = srjson_CreateNull(ctx->jrpl);
}
break;
default:
LM_ERR("Invalid formatting character [%c]\n", fmt);
Expand Down

0 comments on commit 856c563

Please sign in to comment.