FreeSWITCH API Documentation  1.7.0
Data Structures | Macros | Typedefs | Functions
switch_json.h File Reference
#include "switch.h"
+ Include dependency graph for switch_json.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cJSON
 
struct  cJSON_Hooks
 

Macros

#define cJSON_False   0
 
#define cJSON_True   1
 
#define cJSON_NULL   2
 
#define cJSON_Number   3
 
#define cJSON_String   4
 
#define cJSON_Array   5
 
#define cJSON_Object   6
 
#define cJSON_IsReference   256
 
#define cJSON_AddNullToObject(object, name)   cJSON_AddItemToObject(object, name, cJSON_CreateNull())
 
#define cJSON_AddTrueToObject(object, name)   cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
 
#define cJSON_AddFalseToObject(object, name)   cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
 
#define cJSON_AddNumberToObject(object, name, n)   cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
 
#define cJSON_AddStringToObject(object, name, s)   cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
 

Typedefs

typedef struct cJSON cJSON
 
typedef struct cJSON_Hooks cJSON_Hooks
 

Functions

void cJSON_InitHooks (cJSON_Hooks *hooks)
 
cJSONcJSON_Parse (const char *value)
 
char * cJSON_Print (cJSON *item)
 
char * cJSON_PrintUnformatted (cJSON *item)
 
void cJSON_Delete (cJSON *c)
 
int cJSON_GetArraySize (cJSON *array)
 
cJSONcJSON_GetArrayItem (cJSON *array, int item)
 
cJSONcJSON_GetObjectItem (const cJSON *object, const char *string)
 
const char * cJSON_GetObjectCstr (const cJSON *object, const char *string)
 
const char * cJSON_GetErrorPtr (void)
 
cJSONcJSON_CreateNull (void)
 
cJSONcJSON_CreateTrue (void)
 
cJSONcJSON_CreateFalse (void)
 
cJSONcJSON_CreateBool (int b)
 
cJSONcJSON_CreateNumber (double num)
 
cJSONcJSON_CreateString (const char *string)
 
cJSONcJSON_CreateArray (void)
 
cJSONcJSON_CreateObject (void)
 
cJSONcJSON_CreateIntArray (int *numbers, int count)
 
cJSONcJSON_CreateFloatArray (float *numbers, int count)
 
cJSONcJSON_CreateDoubleArray (double *numbers, int count)
 
cJSONcJSON_CreateStringArray (const char **strings, int count)
 
void cJSON_AddItemToArray (cJSON *array, cJSON *item)
 
void cJSON_AddItemToObject (cJSON *object, const char *string, cJSON *item)
 
void cJSON_AddItemReferenceToArray (cJSON *array, cJSON *item)
 
void cJSON_AddItemReferenceToObject (cJSON *object, const char *string, cJSON *item)
 
cJSONcJSON_DetachItemFromArray (cJSON *array, int which)
 
void cJSON_DeleteItemFromArray (cJSON *array, int which)
 
cJSONcJSON_DetachItemFromObject (cJSON *object, const char *string)
 
void cJSON_DeleteItemFromObject (cJSON *object, const char *string)
 
void cJSON_ReplaceItemInArray (cJSON *array, int which, cJSON *newitem)
 
void cJSON_ReplaceItemInObject (cJSON *object, const char *string, cJSON *newitem)
 
cJSONcJSON_Duplicate (cJSON *item, int recurse)
 
cJSONcJSON_CreateStringPrintf (const char *fmt,...)
 
static cJSONjson_add_child_obj (cJSON *json, const char *name, cJSON *obj)
 
static cJSONjson_add_child_array (cJSON *json, const char *name)
 
static cJSONjson_add_child_string (cJSON *json, const char *name, const char *val)
 

Macro Definition Documentation

#define cJSON_AddFalseToObject (   object,
  name 
)    cJSON_AddItemToObject(object, name, cJSON_CreateFalse())

Definition at line 127 of file switch_json.h.

#define cJSON_AddNullToObject (   object,
  name 
)    cJSON_AddItemToObject(object, name, cJSON_CreateNull())

Definition at line 125 of file switch_json.h.

#define cJSON_AddNumberToObject (   object,
  name,
 
)    cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))

Definition at line 128 of file switch_json.h.

#define cJSON_AddStringToObject (   object,
  name,
 
)    cJSON_AddItemToObject(object, name, cJSON_CreateString(s))

Definition at line 129 of file switch_json.h.

#define cJSON_AddTrueToObject (   object,
  name 
)    cJSON_AddItemToObject(object, name, cJSON_CreateTrue())

Definition at line 126 of file switch_json.h.

#define cJSON_Array   5
#define cJSON_False   0

Definition at line 32 of file switch_json.h.

Referenced by cJSON_CreateBool(), cJSON_CreateFalse(), parse_value(), and print_value().

#define cJSON_IsReference   256

Definition at line 40 of file switch_json.h.

Referenced by cJSON_Delete(), cJSON_Duplicate(), and create_reference().

#define cJSON_NULL   2

Definition at line 34 of file switch_json.h.

Referenced by cJSON_CreateNull(), parse_value(), and print_value().

#define cJSON_Number   3

Definition at line 35 of file switch_json.h.

Referenced by cJSON_CreateNumber(), parse_number(), and print_value().

#define cJSON_Object   6

Definition at line 38 of file switch_json.h.

Referenced by cJSON_CreateObject(), parse_object(), and print_value().

#define cJSON_String   4
#define cJSON_True   1

Definition at line 33 of file switch_json.h.

Referenced by cJSON_CreateBool(), cJSON_CreateTrue(), parse_value(), and print_value().

Typedef Documentation

typedef struct cJSON cJSON
typedef struct cJSON_Hooks cJSON_Hooks

Function Documentation

void cJSON_AddItemReferenceToArray ( cJSON array,
cJSON item 
)

Definition at line 521 of file switch_json.c.

References cJSON_AddItemToArray(), and create_reference().

static cJSON * create_reference(cJSON *item)
Definition: switch_json.c:516
void cJSON_AddItemToArray(cJSON *array, cJSON *item)
Definition: switch_json.c:519
void cJSON_AddItemReferenceToObject ( cJSON object,
const char *  string,
cJSON item 
)

Definition at line 522 of file switch_json.c.

References cJSON_AddItemToObject(), and create_reference().

522 {cJSON_AddItemToObject(object,string,create_reference(item));}
static cJSON * create_reference(cJSON *item)
Definition: switch_json.c:516
void cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
Definition: switch_json.c:520
void cJSON_AddItemToArray ( cJSON array,
cJSON item 
)

Definition at line 519 of file switch_json.c.

References cJSON::child, cJSON::next, and suffix_object().

Referenced by cJSON_AddItemReferenceToArray(), cJSON_AddItemToObject(), switch_event_serialize_json_obj(), switch_ivr_generate_json_cdr(), switch_ivr_set_json_call_stats(), and switch_live_array_bootstrap().

519 {cJSON *c=array->child;if (!item) return; if (!c) {array->child=item;} else {while (c && c->next) c=c->next; suffix_object(c,item);}}
struct cJSON * child
Definition: switch_json.h:45
struct cJSON * next
Definition: switch_json.h:44
static void suffix_object(cJSON *prev, cJSON *item)
Definition: switch_json.c:514
void cJSON_AddItemToObject ( cJSON object,
const char *  string,
cJSON item 
)
cJSON* cJSON_CreateArray ( void  )
cJSON* cJSON_CreateBool ( int  b)

Definition at line 540 of file switch_json.c.

References cJSON_False, cJSON_New_Item(), cJSON_True, and cJSON::type.

540 {cJSON *item=cJSON_New_Item();if(item)item->type=b?cJSON_True:cJSON_False;return item;}
#define cJSON_True
Definition: switch_json.h:33
static cJSON * cJSON_New_Item()
Definition: switch_json.c:85
#define cJSON_False
Definition: switch_json.h:32
int type
Definition: switch_json.h:47
cJSON* cJSON_CreateDoubleArray ( double *  numbers,
int  count 
)

Definition at line 549 of file switch_json.c.

References cJSON_CreateArray(), cJSON_CreateNumber(), and suffix_object().

549 {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
static void suffix_object(cJSON *prev, cJSON *item)
Definition: switch_json.c:514
cJSON * cJSON_CreateArray()
Definition: switch_json.c:543
cJSON * cJSON_CreateNumber(double num)
Definition: switch_json.c:541
cJSON* cJSON_CreateFalse ( void  )

Definition at line 539 of file switch_json.c.

References cJSON_False, cJSON_New_Item(), and cJSON::type.

539 {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_False;return item;}
static cJSON * cJSON_New_Item()
Definition: switch_json.c:85
#define cJSON_False
Definition: switch_json.h:32
int type
Definition: switch_json.h:47
cJSON* cJSON_CreateFloatArray ( float *  numbers,
int  count 
)

Definition at line 548 of file switch_json.c.

References cJSON_CreateArray(), cJSON_CreateNumber(), and suffix_object().

548 {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
static void suffix_object(cJSON *prev, cJSON *item)
Definition: switch_json.c:514
cJSON * cJSON_CreateArray()
Definition: switch_json.c:543
cJSON * cJSON_CreateNumber(double num)
Definition: switch_json.c:541
cJSON* cJSON_CreateIntArray ( int *  numbers,
int  count 
)

Definition at line 547 of file switch_json.c.

References cJSON_CreateArray(), cJSON_CreateNumber(), and suffix_object().

547 {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
static void suffix_object(cJSON *prev, cJSON *item)
Definition: switch_json.c:514
cJSON * cJSON_CreateArray()
Definition: switch_json.c:543
cJSON * cJSON_CreateNumber(double num)
Definition: switch_json.c:541
cJSON* cJSON_CreateNull ( void  )

Definition at line 537 of file switch_json.c.

References cJSON_New_Item(), cJSON_NULL, and cJSON::type.

Referenced by switch_json_api_execute().

537 {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;}
static cJSON * cJSON_New_Item()
Definition: switch_json.c:85
int type
Definition: switch_json.h:47
#define cJSON_NULL
Definition: switch_json.h:34
cJSON* cJSON_CreateNumber ( double  num)
cJSON* cJSON_CreateObject ( void  )
cJSON* cJSON_CreateString ( const char *  string)
cJSON* cJSON_CreateStringArray ( const char **  strings,
int  count 
)

Definition at line 550 of file switch_json.c.

References cJSON_CreateArray(), cJSON_CreateString(), and suffix_object().

550 {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateString(strings[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
cJSON * cJSON_CreateString(const char *string)
Definition: switch_json.c:542
static void suffix_object(cJSON *prev, cJSON *item)
Definition: switch_json.c:514
cJSON * cJSON_CreateArray()
Definition: switch_json.c:543
cJSON* cJSON_CreateStringPrintf ( const char *  fmt,
  ... 
)

Definition at line 580 of file switch_json.c.

References cJSON_New_Item(), cJSON_String, switch_vmprintf(), cJSON::type, and cJSON::valuestring.

581 {
582  va_list ap;
583  char *str;
584  cJSON *item;
585 
586  va_start(ap, fmt);
587  str = switch_vmprintf(fmt, ap);
588  va_end(ap);
589 
590  if (!str) return NULL;
591 
592  if ((item = cJSON_New_Item())) {
593  item->type=cJSON_String;
594  item->valuestring = str;
595  } else {
596  free(str);
597  }
598 
599  return item;
600 }
static cJSON * cJSON_New_Item()
Definition: switch_json.c:85
char * valuestring
Definition: switch_json.h:49
#define cJSON_String
Definition: switch_json.h:36
int type
Definition: switch_json.h:47
char * switch_vmprintf(const char *zFormat, va_list ap)
cJSON* cJSON_CreateTrue ( void  )

Definition at line 538 of file switch_json.c.

References cJSON_New_Item(), cJSON_True, and cJSON::type.

538 {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_True;return item;}
#define cJSON_True
Definition: switch_json.h:33
static cJSON * cJSON_New_Item()
Definition: switch_json.c:85
int type
Definition: switch_json.h:47
void cJSON_Delete ( cJSON c)

Definition at line 93 of file switch_json.c.

References cJSON_free, cJSON_IsReference, cJSON::next, and switch_jb_node_s::next.

Referenced by cJSON_DeleteItemFromArray(), cJSON_DeleteItemFromObject(), cJSON_Duplicate(), cJSON_Parse(), cJSON_ReplaceItemInArray(), destroy_ecd(), switch_event_channel_broadcast(), switch_event_create_json(), switch_event_serialize_json(), switch_ivr_multi_threaded_bridge(), switch_ivr_originate(), switch_live_array_add(), and switch_live_array_clear().

94 {
95  cJSON *next;
96  while (c)
97  {
98  next=c->next;
99  if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child);
101  if (c->string) cJSON_free(c->string);
102  cJSON_free(c);
103  c=next;
104  }
105 }
static void(* cJSON_free)(void *ptr)
Definition: switch_json.c:58
char * valuestring
Definition: switch_json.h:49
struct cJSON * child
Definition: switch_json.h:45
char * string
Definition: switch_json.h:53
void cJSON_Delete(cJSON *c)
Definition: switch_json.c:93
struct cJSON * next
Definition: switch_json.h:44
#define cJSON_IsReference
Definition: switch_json.h:40
int type
Definition: switch_json.h:47
void cJSON_DeleteItemFromArray ( cJSON array,
int  which 
)

Definition at line 526 of file switch_json.c.

References cJSON_Delete(), and cJSON_DetachItemFromArray().

cJSON * cJSON_DetachItemFromArray(cJSON *array, int which)
Definition: switch_json.c:524
void cJSON_Delete(cJSON *c)
Definition: switch_json.c:93
void cJSON_DeleteItemFromObject ( cJSON object,
const char *  string 
)

Definition at line 528 of file switch_json.c.

References cJSON_Delete(), and cJSON_DetachItemFromObject().

528 {cJSON_Delete(cJSON_DetachItemFromObject(object,string));}
void cJSON_Delete(cJSON *c)
Definition: switch_json.c:93
cJSON * cJSON_DetachItemFromObject(cJSON *object, const char *string)
Definition: switch_json.c:527
cJSON* cJSON_DetachItemFromArray ( cJSON array,
int  which 
)

Definition at line 524 of file switch_json.c.

References cJSON::child, cJSON::next, and cJSON::prev.

Referenced by cJSON_DeleteItemFromArray(), and cJSON_DetachItemFromObject().

524  {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0;
525  if (c->prev) c->prev->next=c->next;if (c->next) c->next->prev=c->prev;if (c==array->child) array->child=c->next;c->prev=c->next=0;return c;}
struct cJSON * child
Definition: switch_json.h:45
struct cJSON * next
Definition: switch_json.h:44
struct cJSON * prev
Definition: switch_json.h:44
cJSON* cJSON_DetachItemFromObject ( cJSON object,
const char *  string 
)

Definition at line 527 of file switch_json.c.

References cJSON::child, cJSON_DetachItemFromArray(), cJSON_strcasecmp(), cJSON::next, and cJSON::string.

Referenced by cJSON_DeleteItemFromObject().

527 {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;}
cJSON * cJSON_DetachItemFromArray(cJSON *array, int which)
Definition: switch_json.c:524
struct cJSON * child
Definition: switch_json.h:45
char * string
Definition: switch_json.h:53
struct cJSON * next
Definition: switch_json.h:44
static int cJSON_strcasecmp(const char *s1, const char *s2)
Definition: switch_json.c:40
cJSON* cJSON_Duplicate ( cJSON item,
int  recurse 
)

Definition at line 553 of file switch_json.c.

References cJSON::child, cJSON_Delete(), cJSON_IsReference, cJSON_New_Item(), cJSON_strdup(), if(), cJSON::next, cJSON::prev, cJSON::string, cJSON::type, cJSON::valuedouble, cJSON::valueint, and cJSON::valuestring.

Referenced by la_broadcast(), switch_live_array_add(), switch_live_array_bootstrap(), switch_live_array_get(), and switch_live_array_get_idx().

554 {
555  cJSON *newitem,*cptr,*nptr=0,*newchild;
556  /* Bail on bad ptr */
557  if (!item) return 0;
558  /* Create new item */
559  newitem=cJSON_New_Item();
560  if (!newitem) return 0;
561  /* Copy over all vars */
562  newitem->type=item->type&(~cJSON_IsReference),newitem->valueint=item->valueint,newitem->valuedouble=item->valuedouble;
563  if (item->valuestring) {newitem->valuestring=cJSON_strdup(item->valuestring); if (!newitem->valuestring) {cJSON_Delete(newitem);return 0;}}
564  if (item->string) {newitem->string=cJSON_strdup(item->string); if (!newitem->string) {cJSON_Delete(newitem);return 0;}}
565  /* If non-recursive, then we're done! */
566  if (!recurse) return newitem;
567  /* Walk the ->next chain for the child. */
568  cptr=item->child;
569  while (cptr) {
570  newchild=cJSON_Duplicate(cptr,1); /* Duplicate (with recurse) each item in the ->next chain */
571  if (!newchild) {cJSON_Delete(newitem);return 0;}
572  if (nptr) {nptr->next=newchild,newchild->prev=nptr;nptr=newchild;} /* If newitem->child already set, then crosswire ->prev and ->next and move on */
573  else {newitem->child=newchild;nptr=newchild;} /* Set newitem->child and move to it */
574  cptr=cptr->next;
575  }
576  return newitem;
577 }
static cJSON * cJSON_New_Item()
Definition: switch_json.c:85
int valueint
Definition: switch_json.h:50
char * valuestring
Definition: switch_json.h:49
static char * cJSON_strdup(const char *str)
Definition: switch_json.c:60
if((uint32_t)(unpack->cur-unpack->buf) > unpack->buflen)
struct cJSON * child
Definition: switch_json.h:45
char * string
Definition: switch_json.h:53
void cJSON_Delete(cJSON *c)
Definition: switch_json.c:93
struct cJSON * next
Definition: switch_json.h:44
#define cJSON_IsReference
Definition: switch_json.h:40
cJSON * cJSON_Duplicate(cJSON *item, int recurse)
Definition: switch_json.c:553
struct cJSON * prev
Definition: switch_json.h:44
int type
Definition: switch_json.h:47
double valuedouble
Definition: switch_json.h:51
cJSON* cJSON_GetArrayItem ( cJSON array,
int  item 
)

Definition at line 497 of file switch_json.c.

References cJSON::child, and cJSON::next.

Referenced by switch_event_create_json().

497 {cJSON *c=array->child; while (c && item>0) item--,c=c->next; return c;}
struct cJSON * child
Definition: switch_json.h:45
struct cJSON * next
Definition: switch_json.h:44
int cJSON_GetArraySize ( cJSON array)

Definition at line 496 of file switch_json.c.

References cJSON::child, and cJSON::next.

Referenced by switch_event_create_json().

496 {cJSON *c=array->child;int i=0;while(c)i++,c=c->next;return i;}
struct cJSON * child
Definition: switch_json.h:45
struct cJSON * next
Definition: switch_json.h:44
const char* cJSON_GetErrorPtr ( void  )

Definition at line 38 of file switch_json.c.

References ep.

38 {return ep;}
static const char * ep
Definition: switch_json.c:36
const char* cJSON_GetObjectCstr ( const cJSON object,
const char *  string 
)

Definition at line 501 of file switch_json.c.

References cJSON_GetObjectItem(), cJSON_String, cJSON::type, and cJSON::valuestring.

Referenced by switch_live_array_parse_json().

502 {
503  cJSON *cj = cJSON_GetObjectItem(object, string);
504 
505  if (!cj || cj->type != cJSON_String || !cj->valuestring) return NULL;
506 
507  return cj->valuestring;
508 }
cJSON * cJSON_GetObjectItem(const cJSON *object, const char *string)
Definition: switch_json.c:498
char * valuestring
Definition: switch_json.h:49
#define cJSON_String
Definition: switch_json.h:36
int type
Definition: switch_json.h:47
cJSON* cJSON_GetObjectItem ( const cJSON object,
const char *  string 
)

Definition at line 498 of file switch_json.c.

References cJSON::child, cJSON_strcasecmp(), cJSON::next, and cJSON::string.

Referenced by cJSON_GetObjectCstr(), la_broadcast(), switch_json_api_execute(), and switch_live_array_parse_json().

498 {cJSON *c=object->child; while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;}
struct cJSON * child
Definition: switch_json.h:45
char * string
Definition: switch_json.h:53
struct cJSON * next
Definition: switch_json.h:44
static int cJSON_strcasecmp(const char *s1, const char *s2)
Definition: switch_json.c:40
void cJSON_InitHooks ( cJSON_Hooks hooks)

Definition at line 72 of file switch_json.c.

References cJSON_free, and cJSON_malloc.

73 {
74  if (!hooks) { /* Reset hooks */
75  cJSON_malloc = malloc;
76  cJSON_free = free;
77  return;
78  }
79 
80  cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc;
81  cJSON_free = (hooks->free_fn)?hooks->free_fn:free;
82 }
static void(* cJSON_free)(void *ptr)
Definition: switch_json.c:58
void *(* malloc_fn)(size_t sz)
Definition: switch_json.h:57
void(* free_fn)(void *ptr)
Definition: switch_json.h:58
static void *(* cJSON_malloc)(size_t sz)
Definition: switch_json.c:57
cJSON* cJSON_Parse ( const char *  value)

Definition at line 273 of file switch_json.c.

References cJSON_Delete(), cJSON_New_Item(), ep, parse_value(), and skip().

Referenced by switch_event_create_json().

274 {
275  cJSON *c=cJSON_New_Item();
276  ep=0;
277  if (!c) return 0; /* memory fail */
278 
279  if (!parse_value(c,skip(value))) {cJSON_Delete(c);return 0;}
280  return c;
281 }
static const char * parse_value(cJSON *item, const char *value)
Definition: switch_json.c:288
static cJSON * cJSON_New_Item()
Definition: switch_json.c:85
void cJSON_Delete(cJSON *c)
Definition: switch_json.c:93
static const char * ep
Definition: switch_json.c:36
static const char * skip(const char *in)
Definition: switch_json.c:270
char* cJSON_Print ( cJSON item)

Definition at line 284 of file switch_json.c.

References print_value().

284 {return print_value(item,0,1);}
static char * print_value(cJSON *item, int depth, int fmt)
Definition: switch_json.c:303
char* cJSON_PrintUnformatted ( cJSON item)

Definition at line 285 of file switch_json.c.

References print_value().

Referenced by switch_event_serialize_json(), switch_ivr_multi_threaded_bridge(), and switch_ivr_originate().

285 {return print_value(item,0,0);}
static char * print_value(cJSON *item, int depth, int fmt)
Definition: switch_json.c:303
void cJSON_ReplaceItemInArray ( cJSON array,
int  which,
cJSON newitem 
)

Definition at line 531 of file switch_json.c.

References cJSON::child, cJSON_Delete(), cJSON::next, and cJSON::prev.

Referenced by cJSON_ReplaceItemInObject().

531  {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return;
532  newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem;
533  if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=0;cJSON_Delete(c);}
struct cJSON * child
Definition: switch_json.h:45
void cJSON_Delete(cJSON *c)
Definition: switch_json.c:93
struct cJSON * next
Definition: switch_json.h:44
struct cJSON * prev
Definition: switch_json.h:44
void cJSON_ReplaceItemInObject ( cJSON object,
const char *  string,
cJSON newitem 
)

Definition at line 534 of file switch_json.c.

References cJSON::child, cJSON_ReplaceItemInArray(), cJSON_strcasecmp(), cJSON_strdup(), cJSON::next, and cJSON::string.

Referenced by la_broadcast().

534 {int i=0;cJSON *c=object->child;while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}}
void cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem)
Definition: switch_json.c:531
static char * cJSON_strdup(const char *str)
Definition: switch_json.c:60
struct cJSON * child
Definition: switch_json.h:45
char * string
Definition: switch_json.h:53
struct cJSON * next
Definition: switch_json.h:44
static int cJSON_strcasecmp(const char *s1, const char *s2)
Definition: switch_json.c:40
static cJSON* json_add_child_array ( cJSON json,
const char *  name 
)
inlinestatic

Definition at line 152 of file switch_json.h.

References cJSON_AddItemToObject(), cJSON_CreateArray(), and switch_assert.

Referenced by switch_live_array_bootstrap().

153 {
154  cJSON *new_json = NULL;
155 
156  switch_assert(json);
157 
158  new_json = cJSON_CreateArray();
159  switch_assert(new_json);
160 
161  cJSON_AddItemToObject(json, name, new_json);
162 
163  return new_json;
164 }
void cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
Definition: switch_json.c:520
cJSON * cJSON_CreateArray(void)
Definition: switch_json.c:543
#define switch_assert(expr)
static cJSON* json_add_child_obj ( cJSON json,
const char *  name,
cJSON obj 
)
inlinestatic

Definition at line 133 of file switch_json.h.

References cJSON_AddItemToObject(), cJSON_CreateObject(), and switch_assert.

Referenced by switch_live_array_add(), switch_live_array_bootstrap(), switch_live_array_clear(), switch_live_array_del(), and switch_live_array_visible().

134 {
135  cJSON *new_json = NULL;
136 
137  switch_assert(json);
138 
139  if (obj) {
140  new_json = obj;
141  } else {
142  new_json = cJSON_CreateObject();
143  }
144 
145  switch_assert(new_json);
146 
147  cJSON_AddItemToObject(json, name, new_json);
148 
149  return new_json;
150 }
cJSON * cJSON_CreateObject(void)
Definition: switch_json.c:544
void cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
Definition: switch_json.c:520
#define switch_assert(expr)
static cJSON* json_add_child_string ( cJSON json,
const char *  name,
const char *  val 
)
inlinestatic

Definition at line 166 of file switch_json.h.

References cJSON_AddItemToObject(), cJSON_CreateString(), and switch_assert.

Referenced by switch_json_add_presence_data_cols().

167 {
168  cJSON *new_json = NULL;
169 
170  switch_assert(json);
171 
172  new_json = cJSON_CreateString(val);
173  switch_assert(new_json);
174 
175  cJSON_AddItemToObject(json, name, new_json);
176 
177  return new_json;
178 }
void cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
Definition: switch_json.c:520
cJSON * cJSON_CreateString(const char *string)
Definition: switch_json.c:542
#define switch_assert(expr)