| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#ifndef cJSON__h |
| 24 |
#define cJSON__h |
| 25 |
|
| 26 |
#ifdef __cplusplus |
| 27 |
extern "C" |
| 28 |
{ |
| 29 |
#endif |
| 30 |
|
| 31 |
|
| 32 |
#define cJSON_False 0 |
| 33 |
#define cJSON_True 1 |
| 34 |
#define cJSON_NULL 2 |
| 35 |
#define cJSON_Number 3 |
| 36 |
#define cJSON_String 4 |
| 37 |
#define cJSON_Array 5 |
| 38 |
#define cJSON_Object 6 |
| 39 |
|
| 40 |
#define cJSON_IsReference 256 |
| 41 |
|
| 42 |
|
| 43 |
typedef struct cJSON { |
| 44 |
struct cJSON *next,*prev; |
| 45 |
struct cJSON *child; |
| 46 |
|
| 47 |
int type; |
| 48 |
|
| 49 |
char *valuestring; |
| 50 |
int valueint; |
| 51 |
double valuedouble; |
| 52 |
|
| 53 |
char *string; |
| 54 |
} cJSON; |
| 55 |
|
| 56 |
typedef struct cJSON_Hooks { |
| 57 |
void *(*malloc_fn)(size_t sz); |
| 58 |
void (*free_fn)(void *ptr); |
| 59 |
} cJSON_Hooks; |
| 60 |
|
| 61 |
|
| 62 |
extern void cJSON_InitHooks(cJSON_Hooks* hooks); |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
extern cJSON *cJSON_Parse(const char *value); |
| 67 |
|
| 68 |
extern char *cJSON_Print(cJSON *item); |
| 69 |
|
| 70 |
extern char *cJSON_PrintUnformatted(cJSON *item); |
| 71 |
|
| 72 |
extern void cJSON_Delete(cJSON *c); |
| 73 |
|
| 74 |
|
| 75 |
extern int cJSON_GetArraySize(cJSON *array); |
| 76 |
|
| 77 |
extern cJSON *cJSON_GetArrayItem(cJSON *array,int item); |
| 78 |
|
| 79 |
extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string); |
| 80 |
|
| 81 |
|
| 82 |
extern const char *cJSON_GetErrorPtr(void); |
| 83 |
|
| 84 |
|
| 85 |
extern cJSON *cJSON_CreateNull(void); |
| 86 |
extern cJSON *cJSON_CreateTrue(void); |
| 87 |
extern cJSON *cJSON_CreateFalse(void); |
| 88 |
extern cJSON *cJSON_CreateBool(int b); |
| 89 |
extern cJSON *cJSON_CreateNumber(double num); |
| 90 |
extern cJSON *cJSON_CreateString(const char *string); |
| 91 |
extern cJSON *cJSON_CreateArray(void); |
| 92 |
extern cJSON *cJSON_CreateObject(void); |
| 93 |
|
| 94 |
|
| 95 |
extern cJSON *cJSON_CreateIntArray(const int *numbers,int count); |
| 96 |
extern cJSON *cJSON_CreateFloatArray(const float *numbers,int count); |
| 97 |
extern cJSON *cJSON_CreateDoubleArray(const double *numbers,int count); |
| 98 |
extern cJSON *cJSON_CreateStringArray(const char **strings,int count); |
| 99 |
|
| 100 |
|
| 101 |
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item); |
| 102 |
extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item); |
| 103 |
|
| 104 |
extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); |
| 105 |
extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item); |
| 106 |
|
| 107 |
|
| 108 |
extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which); |
| 109 |
extern void cJSON_DeleteItemFromArray(cJSON *array,int which); |
| 110 |
extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string); |
| 111 |
extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string); |
| 112 |
|
| 113 |
|
| 114 |
extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem); |
| 115 |
extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); |
| 116 |
|
| 117 |
|
| 118 |
extern cJSON *cJSON_Duplicate(cJSON *item,int recurse); |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated); |
| 125 |
|
| 126 |
extern void cJSON_Minify(char *json); |
| 127 |
|
| 128 |
|
| 129 |
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull()) |
| 130 |
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue()) |
| 131 |
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse()) |
| 132 |
#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b)) |
| 133 |
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n)) |
| 134 |
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s)) |
| 135 |
|
| 136 |
|
| 137 |
#define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val)) |
| 138 |
|
| 139 |
#ifdef __cplusplus |
| 140 |
} |
| 141 |
#endif |
| 142 |
|
| 143 |
#endif |