RTS API Documentation  1.10.11
Functions
switch_json.c File Reference
#include "switch.h"
+ Include dependency graph for switch_json.c:

Go to the source code of this file.

Functions

cJSONcJSON_CreateStringPrintf (const char *fmt,...)
 
const char * cJSON_GetObjectCstr (const cJSON *object, const char *string)
 

Function Documentation

◆ cJSON_CreateStringPrintf()

cJSON* cJSON_CreateStringPrintf ( const char *  fmt,
  ... 
)

Definition at line 3 of file switch_json.c.

References item, and switch_vmprintf().

4 {
5  va_list ap;
6  char *str;
7  cJSON *item;
8 
9  va_start(ap, fmt);
10  str = switch_vmprintf(fmt, ap);
11  va_end(ap);
12 
13  if (!str) return NULL;
14 
15  item = cJSON_CreateString(str);
16 
17  free(str);
18 
19  return item;
20 }
int cJSON_bool fmt
Definition: switch_cJSON.h:150
cJSON * item
Definition: switch_cJSON.h:210
char * switch_vmprintf(const char *zFormat, va_list ap)

◆ cJSON_GetObjectCstr()

const char* cJSON_GetObjectCstr ( const cJSON object,
const char *  string 
)

Definition at line 22 of file switch_json.c.

References cJSON_String, cJSON::type, and cJSON::valuestring.

Referenced by switch_collect_input_callback(), switch_dial_handle_create_json_obj(), switch_jwt_verify(), switch_live_array_add(), and switch_live_array_parse_json().

23 {
24  cJSON *cj = cJSON_GetObjectItem(object, string);
25 
26  if (!cj || cj->type != cJSON_String || !cj->valuestring) return NULL;
27 
28  return cj->valuestring;
29 }
char * valuestring
Definition: switch_cJSON.h:107
#define cJSON_String
Definition: switch_cJSON.h:86
int type
Definition: switch_cJSON.h:104