modbusd
modbus master daemon
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
cJSON.c File Reference
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <float.h>
#include <limits.h>
#include <ctype.h>
#include "cJSON.h"
Include dependency graph for cJSON.c:

Data Structures

struct  printbuffer
 

Functions

const char * cJSON_GetErrorPtr (void)
 
void cJSON_InitHooks (cJSON_Hooks *hooks)
 
void cJSON_Delete (cJSON *c)
 
cJSONcJSON_ParseWithOpts (const char *value, const char **return_parse_end, int require_null_terminated)
 
cJSONcJSON_Parse (const char *value)
 
char * cJSON_Print (cJSON *item)
 
char * cJSON_PrintUnformatted (cJSON *item)
 
char * cJSON_PrintBuffered (cJSON *item, int prebuffer, int fmt)
 
int cJSON_GetArraySize (cJSON *array)
 
cJSONcJSON_GetArrayItem (cJSON *array, int item)
 
cJSONcJSON_GetObjectItem (cJSON *object, const char *string)
 
int cJSON_HasObjectItem (cJSON *object, const char *string)
 
void cJSON_AddItemToArray (cJSON *array, cJSON *item)
 
void cJSON_AddItemToObject (cJSON *object, const char *string, cJSON *item)
 
void cJSON_AddItemToObjectCS (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_InsertItemInArray (cJSON *array, int which, cJSON *newitem)
 
void cJSON_ReplaceItemInArray (cJSON *array, int which, cJSON *newitem)
 
void cJSON_ReplaceItemInObject (cJSON *object, const char *string, cJSON *newitem)
 
cJSONcJSON_CreateNull (void)
 
cJSONcJSON_CreateTrue (void)
 
cJSONcJSON_CreateFalse (void)
 
cJSONcJSON_CreateBool (int b)
 
cJSONcJSON_CreateUInt8 (double num)
 
cJSONcJSON_CreateUInt16 (double num)
 
cJSONcJSON_CreateNumber (double num)
 
cJSONcJSON_CreateString (const char *string)
 
cJSONcJSON_CreateArray (void)
 
cJSONcJSON_CreateObject (void)
 
cJSONcJSON_CreateUInt8Array (const uint8_t *numbers, int count)
 
cJSONcJSON_CreateUInt16Array (const uint16_t *numbers, int count)
 
cJSONcJSON_CreateIntArray (const int *numbers, int count)
 
cJSONcJSON_CreateFloatArray (const float *numbers, int count)
 
cJSONcJSON_CreateDoubleArray (const double *numbers, int count)
 
cJSONcJSON_CreateStringArray (const char **strings, int count)
 
cJSONcJSON_Duplicate (cJSON *item, int recurse)
 
void cJSON_Minify (char *json)
 

Function Documentation

void cJSON_AddItemReferenceToArray ( cJSON array,
cJSON item 
)

References cJSON_AddItemToArray().

678 {cJSON_AddItemToArray(array,create_reference(item));}
void cJSON_AddItemToArray(cJSON *array, cJSON *item)
Definition: cJSON.c:675

Here is the call graph for this function:

void cJSON_AddItemReferenceToObject ( cJSON object,
const char *  string,
cJSON item 
)

References cJSON_AddItemToObject().

679 {cJSON_AddItemToObject(object,string,create_reference(item));}
void cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
Definition: cJSON.c:676

Here is the call graph for this function:

void cJSON_AddItemToArray ( cJSON array,
cJSON item 
)

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

Referenced by cJSON_AddItemReferenceToArray(), cJSON_AddItemToObject(), cJSON_AddItemToObjectCS(), and cJSON_InsertItemInArray().

675 {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 * next
Definition: cJSON.h:48
struct cJSON * child
Definition: cJSON.h:49
Definition: cJSON.h:47

Here is the caller graph for this function:

void cJSON_AddItemToObject ( cJSON object,
const char *  string,
cJSON item 
)

References cJSON_AddItemToArray(), and cJSON::string.

Referenced by cJSON_AddItemReferenceToObject(), cJSONUtils_GenerateMergePatch(), cJSONUtils_MergePatch(), set_modbus_success_resp_str_with_data(), and test_json_encode().

676 {if (!item) return; if (item->string) cJSON_free(item->string);item->string=cJSON_strdup(string);cJSON_AddItemToArray(object,item);}
void cJSON_AddItemToArray(cJSON *array, cJSON *item)
Definition: cJSON.c:675
char * string
Definition: cJSON.h:59

Here is the call graph for this function:

Here is the caller graph for this function:

void cJSON_AddItemToObjectCS ( cJSON object,
const char *  string,
cJSON item 
)

References cJSON_AddItemToArray(), cJSON_StringIsConst, cJSON::string, and cJSON::type.

677 {if (!item) return; if (!(item->type&cJSON_StringIsConst) && item->string) cJSON_free(item->string);item->string=(char*)string;item->type|=cJSON_StringIsConst;cJSON_AddItemToArray(object,item);}
int type
Definition: cJSON.h:50
void cJSON_AddItemToArray(cJSON *array, cJSON *item)
Definition: cJSON.c:675
char * string
Definition: cJSON.h:59
#define cJSON_StringIsConst
Definition: cJSON.h:44

Here is the call graph for this function:

cJSON* cJSON_CreateArray ( void  )

References cJSON_Array, and cJSON::type.

Referenced by cJSON_CreateDoubleArray(), cJSON_CreateFloatArray(), cJSON_CreateIntArray(), cJSON_CreateStringArray(), cJSON_CreateUInt16Array(), cJSON_CreateUInt8Array(), and cJSONUtils_GeneratePatches().

707 {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Array;return item;}
#define cJSON_Array
Definition: cJSON.h:40
int type
Definition: cJSON.h:50
Definition: cJSON.h:47

Here is the caller graph for this function:

cJSON* cJSON_CreateBool ( int  b)

References cJSON_False, cJSON_True, and cJSON::type.

699 {cJSON *item=cJSON_New_Item();if(item)item->type=b?cJSON_True:cJSON_False;return item;}
#define cJSON_False
Definition: cJSON.h:35
#define cJSON_True
Definition: cJSON.h:36
int type
Definition: cJSON.h:50
Definition: cJSON.h:47
cJSON* cJSON_CreateDoubleArray ( const double *  numbers,
int  count 
)

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

717 {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!n){cJSON_Delete(a);return 0;}if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
cJSON * cJSON_CreateNumber(double num)
Definition: cJSON.c:705
void cJSON_Delete(cJSON *c)
Definition: cJSON.c:81
cJSON * cJSON_CreateArray(void)
Definition: cJSON.c:707
Definition: cJSON.h:47

Here is the call graph for this function:

cJSON* cJSON_CreateFalse ( void  )

References cJSON_False, and cJSON::type.

698 {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_False;return item;}
#define cJSON_False
Definition: cJSON.h:35
int type
Definition: cJSON.h:50
Definition: cJSON.h:47
cJSON* cJSON_CreateFloatArray ( const float *  numbers,
int  count 
)

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

716 {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!n){cJSON_Delete(a);return 0;}if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
cJSON * cJSON_CreateNumber(double num)
Definition: cJSON.c:705
void cJSON_Delete(cJSON *c)
Definition: cJSON.c:81
cJSON * cJSON_CreateArray(void)
Definition: cJSON.c:707
Definition: cJSON.h:47

Here is the call graph for this function:

cJSON* cJSON_CreateIntArray ( const int *  numbers,
int  count 
)

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

Referenced by test_json_encode().

715 {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!n){cJSON_Delete(a);return 0;}if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
cJSON * cJSON_CreateNumber(double num)
Definition: cJSON.c:705
void cJSON_Delete(cJSON *c)
Definition: cJSON.c:81
cJSON * cJSON_CreateArray(void)
Definition: cJSON.c:707
Definition: cJSON.h:47

Here is the call graph for this function:

Here is the caller graph for this function:

cJSON* cJSON_CreateNull ( void  )

References cJSON_NULL, and cJSON::type.

Referenced by cJSONUtils_GenerateMergePatch().

696 {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;}
#define cJSON_NULL
Definition: cJSON.h:37
int type
Definition: cJSON.h:50
Definition: cJSON.h:47

Here is the caller graph for this function:

cJSON* cJSON_CreateNumber ( double  num)

References cJSON_Number, cJSON::type, cJSON::valuedouble, and cJSON::valueint.

Referenced by cJSON_CreateDoubleArray(), cJSON_CreateFloatArray(), and cJSON_CreateIntArray().

705 {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueint=(long)num;}return item;}
int valueint
Definition: cJSON.h:57
int type
Definition: cJSON.h:50
double valuedouble
Definition: cJSON.h:58
Definition: cJSON.h:47
#define cJSON_Number
Definition: cJSON.h:38

Here is the caller graph for this function:

cJSON* cJSON_CreateObject ( void  )

References cJSON_Object, and cJSON::type.

Referenced by cJSONUtils_GenerateMergePatch(), cJSONUtils_MergePatch(), mbtcp_get_response_timeout(), mbtcp_set_response_timeout(), set_modbus_fail_resp_str(), set_modbus_success_resp_str_with_data(), and test_json_encode().

708 {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;return item;}
#define cJSON_Object
Definition: cJSON.h:41
int type
Definition: cJSON.h:50
Definition: cJSON.h:47

Here is the caller graph for this function:

cJSON* cJSON_CreateString ( const char *  string)

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

Referenced by cJSON_CreateStringArray().

706 {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_String;item->valuestring=cJSON_strdup(string);if(!item->valuestring){cJSON_Delete(item);return 0;}}return item;}
#define cJSON_String
Definition: cJSON.h:39
void cJSON_Delete(cJSON *c)
Definition: cJSON.c:81
int type
Definition: cJSON.h:50
Definition: cJSON.h:47
char * valuestring
Definition: cJSON.h:51

Here is the call graph for this function:

Here is the caller graph for this function:

cJSON* cJSON_CreateStringArray ( const char **  strings,
int  count 
)

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

718 {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateString(strings[i]);if(!n){cJSON_Delete(a);return 0;}if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
void cJSON_Delete(cJSON *c)
Definition: cJSON.c:81
cJSON * cJSON_CreateArray(void)
Definition: cJSON.c:707
cJSON * cJSON_CreateString(const char *string)
Definition: cJSON.c:706
Definition: cJSON.h:47

Here is the call graph for this function:

cJSON* cJSON_CreateTrue ( void  )

References cJSON_True, and cJSON::type.

697 {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_True;return item;}
#define cJSON_True
Definition: cJSON.h:36
int type
Definition: cJSON.h:50
Definition: cJSON.h:47
cJSON* cJSON_CreateUInt16 ( double  num)

References cJSON_Number, cJSON::type, cJSON::valuedouble, and cJSON::valueuint16.

Referenced by cJSON_CreateUInt16Array().

703 {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueuint16=(uint16_t)num;}return item;}
int type
Definition: cJSON.h:50
double valuedouble
Definition: cJSON.h:58
Definition: cJSON.h:47
uint16_t valueuint16
Definition: cJSON.h:55
#define cJSON_Number
Definition: cJSON.h:38

Here is the caller graph for this function:

cJSON* cJSON_CreateUInt16Array ( const uint16_t *  numbers,
int  count 
)

References cJSON_CreateArray(), cJSON_CreateUInt16(), and cJSON_Delete().

Referenced by mbtcp_read_reg_req_fn().

713 {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateUInt16(numbers[i]);if(!n){cJSON_Delete(a);return 0;}if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
void cJSON_Delete(cJSON *c)
Definition: cJSON.c:81
cJSON * cJSON_CreateArray(void)
Definition: cJSON.c:707
cJSON * cJSON_CreateUInt16(double num)
Definition: cJSON.c:703
Definition: cJSON.h:47

Here is the call graph for this function:

Here is the caller graph for this function:

cJSON* cJSON_CreateUInt8 ( double  num)

References cJSON_Number, cJSON::type, cJSON::valuedouble, and cJSON::valueuint8.

Referenced by cJSON_CreateUInt8Array().

702 {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueuint8=(uint8_t)num;}return item;}
uint8_t valueuint8
Definition: cJSON.h:54
int type
Definition: cJSON.h:50
unsigned char uint8_t
Definition: uthash.h:78
double valuedouble
Definition: cJSON.h:58
Definition: cJSON.h:47
#define cJSON_Number
Definition: cJSON.h:38

Here is the caller graph for this function:

cJSON* cJSON_CreateUInt8Array ( const uint8_t numbers,
int  count 
)

References cJSON_CreateArray(), cJSON_CreateUInt8(), and cJSON_Delete().

Referenced by mbtcp_read_bit_req_fn().

712 {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateUInt8(numbers[i]);if(!n){cJSON_Delete(a);return 0;}if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
void cJSON_Delete(cJSON *c)
Definition: cJSON.c:81
cJSON * cJSON_CreateArray(void)
Definition: cJSON.c:707
cJSON * cJSON_CreateUInt8(double num)
Definition: cJSON.c:702
Definition: cJSON.h:47

Here is the call graph for this function:

Here is the caller graph for this function:

void cJSON_Delete ( cJSON c)

References cJSON::child, cJSON_Delete(), cJSON_IsReference, cJSON_StringIsConst, cJSON::next, cJSON::string, cJSON::type, and cJSON::valuestring.

Referenced by cJSON_CreateDoubleArray(), cJSON_CreateFloatArray(), cJSON_CreateIntArray(), cJSON_CreateString(), cJSON_CreateStringArray(), cJSON_CreateUInt16Array(), cJSON_CreateUInt8Array(), cJSON_Delete(), cJSON_DeleteItemFromArray(), cJSON_DeleteItemFromObject(), cJSON_Duplicate(), cJSON_ParseWithOpts(), cJSON_ReplaceItemInArray(), cJSONUtils_GenerateMergePatch(), cJSONUtils_MergePatch(), main(), mbtcp_get_response_timeout(), mbtcp_set_response_timeout(), set_modbus_fail_resp_str(), set_modbus_success_resp_str_with_data(), test_json_decode(), and test_json_encode().

82 {
83  cJSON *next;
84  while (c)
85  {
86  next=c->next;
87  if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child);
88  if (!(c->type&cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring);
89  if (!(c->type&cJSON_StringIsConst) && c->string) cJSON_free(c->string);
90  cJSON_free(c);
91  c=next;
92  }
93 }
struct cJSON * next
Definition: cJSON.h:48
struct cJSON * child
Definition: cJSON.h:49
void cJSON_Delete(cJSON *c)
Definition: cJSON.c:81
int type
Definition: cJSON.h:50
char * string
Definition: cJSON.h:59
void * next
Definition: uthash.h:1066
#define cJSON_StringIsConst
Definition: cJSON.h:44
Definition: cJSON.h:47
#define cJSON_IsReference
Definition: cJSON.h:43
char * valuestring
Definition: cJSON.h:51

Here is the call graph for this function:

Here is the caller graph for this function:

void cJSON_DeleteItemFromArray ( cJSON array,
int  which 
)

References cJSON_Delete(), and cJSON_DetachItemFromArray().

cJSON * cJSON_DetachItemFromArray(cJSON *array, int which)
Definition: cJSON.c:681
void cJSON_Delete(cJSON *c)
Definition: cJSON.c:81

Here is the call graph for this function:

void cJSON_DeleteItemFromObject ( cJSON object,
const char *  string 
)

References cJSON_Delete(), and cJSON_DetachItemFromObject().

Referenced by cJSONUtils_MergePatch().

685 {cJSON_Delete(cJSON_DetachItemFromObject(object,string));}
cJSON * cJSON_DetachItemFromObject(cJSON *object, const char *string)
Definition: cJSON.c:684
void cJSON_Delete(cJSON *c)
Definition: cJSON.c:81

Here is the call graph for this function:

Here is the caller graph for this function:

cJSON* cJSON_DetachItemFromArray ( cJSON array,
int  which 
)

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

Referenced by cJSON_DeleteItemFromArray(), and cJSON_DetachItemFromObject().

681  {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0;
682  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 * next
Definition: cJSON.h:48
struct cJSON * child
Definition: cJSON.h:49
struct cJSON * prev
Definition: cJSON.h:48
Definition: cJSON.h:47

Here is the caller graph for this function:

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

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

Referenced by cJSON_DeleteItemFromObject(), and cJSONUtils_MergePatch().

684 {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;}
struct cJSON * next
Definition: cJSON.h:48
struct cJSON * child
Definition: cJSON.h:49
cJSON * cJSON_DetachItemFromArray(cJSON *array, int which)
Definition: cJSON.c:681
char * string
Definition: cJSON.h:59
Definition: cJSON.h:47

Here is the call graph for this function:

Here is the caller graph for this function:

cJSON* cJSON_Duplicate ( cJSON item,
int  recurse 
)

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

Referenced by cJSON_Duplicate(), cJSONUtils_GenerateMergePatch(), and cJSONUtils_MergePatch().

722 {
723  cJSON *newitem,*cptr,*nptr=0,*newchild;
724  /* Bail on bad ptr */
725  if (!item) return 0;
726  /* Create new item */
727  newitem=cJSON_New_Item();
728  if (!newitem) return 0;
729  /* Copy over all vars */
730  newitem->type=item->type&(~cJSON_IsReference),newitem->valueint=item->valueint,newitem->valuedouble=item->valuedouble;
731  if (item->valuestring) {newitem->valuestring=cJSON_strdup(item->valuestring); if (!newitem->valuestring) {cJSON_Delete(newitem);return 0;}}
732  if (item->string) {newitem->string=cJSON_strdup(item->string); if (!newitem->string) {cJSON_Delete(newitem);return 0;}}
733  /* If non-recursive, then we're done! */
734  if (!recurse) return newitem;
735  /* Walk the ->next chain for the child. */
736  cptr=item->child;
737  while (cptr)
738  {
739  newchild=cJSON_Duplicate(cptr,1); /* Duplicate (with recurse) each item in the ->next chain */
740  if (!newchild) {cJSON_Delete(newitem);return 0;}
741  if (nptr) {nptr->next=newchild,newchild->prev=nptr;nptr=newchild;} /* If newitem->child already set, then crosswire ->prev and ->next and move on */
742  else {newitem->child=newchild;nptr=newchild;} /* Set newitem->child and move to it */
743  cptr=cptr->next;
744  }
745  return newitem;
746 }
struct cJSON * next
Definition: cJSON.h:48
struct cJSON * child
Definition: cJSON.h:49
int valueint
Definition: cJSON.h:57
cJSON * cJSON_Duplicate(cJSON *item, int recurse)
Definition: cJSON.c:721
struct cJSON * prev
Definition: cJSON.h:48
void cJSON_Delete(cJSON *c)
Definition: cJSON.c:81
int type
Definition: cJSON.h:50
char * string
Definition: cJSON.h:59
double valuedouble
Definition: cJSON.h:58
Definition: cJSON.h:47
#define cJSON_IsReference
Definition: cJSON.h:43
char * valuestring
Definition: cJSON.h:51

Here is the call graph for this function:

Here is the caller graph for this function:

cJSON* cJSON_GetArrayItem ( cJSON array,
int  item 
)

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

Referenced by cJSONUtils_GetPointer(), mbtcp_multi_write_req_fn(), and test_json_decode().

665 {cJSON *c=array?array->child:0;while (c && item>0) item--,c=c->next; return c;}
struct cJSON * next
Definition: cJSON.h:48
struct cJSON * child
Definition: cJSON.h:49
Definition: cJSON.h:47

Here is the caller graph for this function:

int cJSON_GetArraySize ( cJSON array)

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

Referenced by mbtcp_multi_write_req_fn(), and test_json_decode().

664 {cJSON *c=array->child;int i=0;while(c)i++,c=c->next;return i;}
struct cJSON * next
Definition: cJSON.h:48
struct cJSON * child
Definition: cJSON.h:49
Definition: cJSON.h:47

Here is the caller graph for this function:

const char* cJSON_GetErrorPtr ( void  )
37 {return global_ep;}
cJSON* cJSON_GetObjectItem ( cJSON object,
const char *  string 
)

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

Referenced by cJSON_HasObjectItem(), json_get_char(), json_get_double(), json_get_int(), json_get_long(), json_set_double(), json_set_int(), mbtcp_multi_write_req_fn(), and test_json_decode().

666 {cJSON *c=object?object->child:0;while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;}
struct cJSON * next
Definition: cJSON.h:48
struct cJSON * child
Definition: cJSON.h:49
char * string
Definition: cJSON.h:59
Definition: cJSON.h:47

Here is the caller graph for this function:

int cJSON_HasObjectItem ( cJSON object,
const char *  string 
)

References cJSON_GetObjectItem().

667 {return cJSON_GetObjectItem(object,string)?1:0;}
cJSON * cJSON_GetObjectItem(cJSON *object, const char *string)
Definition: cJSON.c:666

Here is the call graph for this function:

void cJSON_InitHooks ( cJSON_Hooks hooks)

References cJSON_Hooks::free_fn, and cJSON_Hooks::malloc_fn.

61 {
62  if (!hooks) { /* Reset hooks */
63  cJSON_malloc = malloc;
64  cJSON_free = free;
65  return;
66  }
67 
68  cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc;
69  cJSON_free = (hooks->free_fn)?hooks->free_fn:free;
70 }
void *(* malloc_fn)(size_t sz)
Definition: cJSON.h:63
void(* free_fn)(void *ptr)
Definition: cJSON.h:64
void cJSON_InsertItemInArray ( cJSON array,
int  which,
cJSON newitem 
)

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

688  {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) {cJSON_AddItemToArray(array,newitem);return;}
689  newitem->next=c;newitem->prev=c->prev;c->prev=newitem;if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;}
struct cJSON * next
Definition: cJSON.h:48
struct cJSON * child
Definition: cJSON.h:49
struct cJSON * prev
Definition: cJSON.h:48
void cJSON_AddItemToArray(cJSON *array, cJSON *item)
Definition: cJSON.c:675
Definition: cJSON.h:47

Here is the call graph for this function:

void cJSON_Minify ( char *  json)
749 {
750  char *into=json;
751  while (*json)
752  {
753  if (*json==' ') json++;
754  else if (*json=='\t') json++; /* Whitespace characters. */
755  else if (*json=='\r') json++;
756  else if (*json=='\n') json++;
757  else if (*json=='/' && json[1]=='/') while (*json && *json!='\n') json++; /* double-slash comments, to end of line. */
758  else if (*json=='/' && json[1]=='*') {while (*json && !(*json=='*' && json[1]=='/')) json++;json+=2;} /* multiline comments. */
759  else if (*json=='\"'){*into++=*json++;while (*json && *json!='\"'){if (*json=='\\') *into++=*json++;*into++=*json++;}*into++=*json++;} /* string literals, which are \" sensitive. */
760  else *into++=*json++; /* All other characters. */
761  }
762  *into=0; /* and null-terminate. */
763 }
cJSON* cJSON_Parse ( const char *  value)

References cJSON_ParseWithOpts().

Referenced by file_to_json(), main(), and test_json_decode().

343 {return cJSON_ParseWithOpts(value,0,0);}
cJSON * cJSON_ParseWithOpts(const char *value, const char **return_parse_end, int require_null_terminated)
Definition: cJSON.c:327

Here is the call graph for this function:

Here is the caller graph for this function:

cJSON* cJSON_ParseWithOpts ( const char *  value,
const char **  return_parse_end,
int  require_null_terminated 
)

References cJSON_Delete().

Referenced by cJSON_Parse().

328 {
329  const char *end=0,**ep=return_parse_end?return_parse_end:&global_ep;
330  cJSON *c=cJSON_New_Item();
331  *ep=0;
332  if (!c) return 0; /* memory fail */
333 
334  end=parse_value(c,skip(value),ep);
335  if (!end) {cJSON_Delete(c);return 0;} /* parse failure. ep is set. */
336 
337  /* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */
338  if (require_null_terminated) {end=skip(end);if (*end) {cJSON_Delete(c);*ep=end;return 0;}}
339  if (return_parse_end) *return_parse_end=end;
340  return c;
341 }
void cJSON_Delete(cJSON *c)
Definition: cJSON.c:81
Definition: cJSON.h:47

Here is the call graph for this function:

Here is the caller graph for this function:

char* cJSON_Print ( cJSON item)

Referenced by json_to_file(), test_json_decode(), and test_json_encode().

346 {return print_value(item,0,1,0);}

Here is the caller graph for this function:

char* cJSON_PrintBuffered ( cJSON item,
int  prebuffer,
int  fmt 
)

References printbuffer::buffer, printbuffer::length, and printbuffer::offset.

350 {
351  printbuffer p;
352  p.buffer=(char*)cJSON_malloc(prebuffer);
353  p.length=prebuffer;
354  p.offset=0;
355  return print_value(item,0,fmt,&p);
356 }
Definition: cJSON.c:119
char * buffer
Definition: cJSON.c:119
int length
Definition: cJSON.c:119
int offset
Definition: cJSON.c:119
char* cJSON_PrintUnformatted ( cJSON item)

Referenced by mbtcp_get_response_timeout(), mbtcp_set_response_timeout(), set_modbus_fail_resp_str(), and set_modbus_success_resp_str_with_data().

347 {return print_value(item,0,0,0);}

Here is the caller graph for this function:

void cJSON_ReplaceItemInArray ( cJSON array,
int  which,
cJSON newitem 
)

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

Referenced by cJSON_ReplaceItemInObject().

690  {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return;
691  newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem;
692  if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=0;cJSON_Delete(c);}
struct cJSON * next
Definition: cJSON.h:48
struct cJSON * child
Definition: cJSON.h:49
struct cJSON * prev
Definition: cJSON.h:48
void cJSON_Delete(cJSON *c)
Definition: cJSON.c:81
Definition: cJSON.h:47

Here is the call graph for this function:

Here is the caller graph for this function:

void cJSON_ReplaceItemInObject ( cJSON object,
const char *  string,
cJSON newitem 
)

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

693 {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: cJSON.c:690
struct cJSON * next
Definition: cJSON.h:48
struct cJSON * child
Definition: cJSON.h:49
char * string
Definition: cJSON.h:59
Definition: cJSON.h:47

Here is the call graph for this function: