File indexing completed on 2025-06-03 08:32:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #ifndef cJSON__h
0024 #define cJSON__h
0025
0026 #ifdef __cplusplus
0027 extern "C"
0028 {
0029 #endif
0030
0031 #if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
0032 #define __WINDOWS__
0033 #endif
0034
0035 #ifdef __WINDOWS__
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 #define CJSON_CDECL __cdecl
0056 #define CJSON_STDCALL __stdcall
0057
0058
0059 #if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
0060 #define CJSON_EXPORT_SYMBOLS
0061 #endif
0062
0063 #if defined(CJSON_HIDE_SYMBOLS)
0064 #define CJSON_PUBLIC(type) type CJSON_STDCALL
0065 #elif defined(CJSON_EXPORT_SYMBOLS)
0066 #define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
0067 #elif defined(CJSON_IMPORT_SYMBOLS)
0068 #define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
0069 #endif
0070 #else
0071 #define CJSON_CDECL
0072 #define CJSON_STDCALL
0073
0074 #if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
0075 #define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
0076 #else
0077 #define CJSON_PUBLIC(type) type
0078 #endif
0079 #endif
0080
0081
0082 #define CJSON_VERSION_MAJOR 1
0083 #define CJSON_VERSION_MINOR 7
0084 #define CJSON_VERSION_PATCH 18
0085
0086 #include <stddef.h>
0087
0088
0089 #define cJSON_Invalid (0)
0090 #define cJSON_False (1 << 0)
0091 #define cJSON_True (1 << 1)
0092 #define cJSON_NULL (1 << 2)
0093 #define cJSON_Number (1 << 3)
0094 #define cJSON_String (1 << 4)
0095 #define cJSON_Array (1 << 5)
0096 #define cJSON_Object (1 << 6)
0097 #define cJSON_Raw (1 << 7)
0098
0099 #define cJSON_IsReference 256
0100 #define cJSON_StringIsConst 512
0101
0102
0103 typedef struct cJSON
0104 {
0105
0106 struct cJSON *next;
0107 struct cJSON *prev;
0108
0109 struct cJSON *child;
0110
0111
0112 int type;
0113
0114
0115 char *valuestring;
0116
0117 int valueint;
0118
0119 double valuedouble;
0120
0121
0122 char *string;
0123 } cJSON;
0124
0125 typedef struct cJSON_Hooks
0126 {
0127
0128 void *(CJSON_CDECL *malloc_fn)(size_t sz);
0129 void (CJSON_CDECL *free_fn)(void *ptr);
0130 } cJSON_Hooks;
0131
0132 typedef int cJSON_bool;
0133
0134
0135
0136 #ifndef CJSON_NESTING_LIMIT
0137 #define CJSON_NESTING_LIMIT 1000
0138 #endif
0139
0140
0141 CJSON_PUBLIC(const char*) cJSON_Version(void);
0142
0143
0144 CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
0145
0146
0147
0148 CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
0149 CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length);
0150
0151
0152 CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
0153 CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated);
0154
0155
0156 CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
0157
0158 CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
0159
0160 CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
0161
0162
0163 CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
0164
0165 CJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
0166
0167
0168 CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
0169
0170 CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
0171
0172 CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
0173 CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
0174 CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
0175
0176 CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
0177
0178
0179 CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
0180 CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item);
0181
0182
0183 CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
0184 CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
0185 CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
0186 CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
0187 CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
0188 CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
0189 CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
0190 CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
0191 CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
0192 CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
0193
0194
0195 CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
0196 CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
0197 CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
0198 CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
0199 CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
0200 CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
0201
0202 CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
0203 CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
0204 CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
0205
0206
0207
0208 CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
0209
0210
0211 CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
0212 CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
0213
0214
0215
0216 CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
0217 CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
0218 CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
0219 CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count);
0220
0221
0222 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
0223 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
0224
0225
0226
0227 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
0228
0229 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
0230 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
0231
0232
0233 CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
0234 CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
0235 CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
0236 CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
0237 CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
0238 CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
0239 CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
0240
0241
0242 CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem);
0243 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
0244 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
0245 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
0246 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
0247
0248
0249 CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
0250
0251
0252
0253
0254
0255 CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
0256
0257
0258
0259
0260 CJSON_PUBLIC(void) cJSON_Minify(char *json);
0261
0262
0263
0264 CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
0265 CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
0266 CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
0267 CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
0268 CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
0269 CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
0270 CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
0271 CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
0272 CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
0273
0274
0275 #define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
0276
0277 CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
0278 #define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
0279
0280 CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
0281
0282
0283 #define cJSON_SetBoolValue(object, boolValue) ( \
0284 (object != NULL && ((object)->type & (cJSON_False|cJSON_True))) ? \
0285 (object)->type=((object)->type &(~(cJSON_False|cJSON_True)))|((boolValue)?cJSON_True:cJSON_False) : \
0286 cJSON_Invalid\
0287 )
0288
0289
0290 #define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
0291
0292
0293 CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
0294 CJSON_PUBLIC(void) cJSON_free(void *object);
0295
0296 #ifdef __cplusplus
0297 }
0298 #endif
0299
0300 #endif