19750e409Sopenharmony_ci/*
29750e409Sopenharmony_ci  Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
39750e409Sopenharmony_ci
49750e409Sopenharmony_ci  Permission is hereby granted, free of charge, to any person obtaining a copy
59750e409Sopenharmony_ci  of this software and associated documentation files (the "Software"), to deal
69750e409Sopenharmony_ci  in the Software without restriction, including without limitation the rights
79750e409Sopenharmony_ci  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
89750e409Sopenharmony_ci  copies of the Software, and to permit persons to whom the Software is
99750e409Sopenharmony_ci  furnished to do so, subject to the following conditions:
109750e409Sopenharmony_ci
119750e409Sopenharmony_ci  The above copyright notice and this permission notice shall be included in
129750e409Sopenharmony_ci  all copies or substantial portions of the Software.
139750e409Sopenharmony_ci
149750e409Sopenharmony_ci  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
159750e409Sopenharmony_ci  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
169750e409Sopenharmony_ci  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
179750e409Sopenharmony_ci  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
189750e409Sopenharmony_ci  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
199750e409Sopenharmony_ci  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
209750e409Sopenharmony_ci  THE SOFTWARE.
219750e409Sopenharmony_ci*/
229750e409Sopenharmony_ci
239750e409Sopenharmony_ci#ifndef cJSON__h
249750e409Sopenharmony_ci#define cJSON__h
259750e409Sopenharmony_ci
269750e409Sopenharmony_ci#ifdef __cplusplus
279750e409Sopenharmony_ciextern "C"
289750e409Sopenharmony_ci{
299750e409Sopenharmony_ci#endif
309750e409Sopenharmony_ci
319750e409Sopenharmony_ci#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
329750e409Sopenharmony_ci#define __WINDOWS__
339750e409Sopenharmony_ci#endif
349750e409Sopenharmony_ci
359750e409Sopenharmony_ci#ifdef __WINDOWS__
369750e409Sopenharmony_ci
379750e409Sopenharmony_ci/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention.  For windows you have 3 define options:
389750e409Sopenharmony_ci
399750e409Sopenharmony_ciCJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
409750e409Sopenharmony_ciCJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
419750e409Sopenharmony_ciCJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
429750e409Sopenharmony_ci
439750e409Sopenharmony_ciFor *nix builds that support visibility attribute, you can define similar behavior by
449750e409Sopenharmony_ci
459750e409Sopenharmony_cisetting default visibility to hidden by adding
469750e409Sopenharmony_ci-fvisibility=hidden (for gcc)
479750e409Sopenharmony_cior
489750e409Sopenharmony_ci-xldscope=hidden (for sun cc)
499750e409Sopenharmony_cito CFLAGS
509750e409Sopenharmony_ci
519750e409Sopenharmony_cithen using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
529750e409Sopenharmony_ci
539750e409Sopenharmony_ci*/
549750e409Sopenharmony_ci
559750e409Sopenharmony_ci#define CJSON_CDECL __cdecl
569750e409Sopenharmony_ci#define CJSON_STDCALL __stdcall
579750e409Sopenharmony_ci
589750e409Sopenharmony_ci/* export symbols by default, this is necessary for copy pasting the C and header file */
599750e409Sopenharmony_ci#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
609750e409Sopenharmony_ci#define CJSON_EXPORT_SYMBOLS
619750e409Sopenharmony_ci#endif
629750e409Sopenharmony_ci
639750e409Sopenharmony_ci#if defined(CJSON_HIDE_SYMBOLS)
649750e409Sopenharmony_ci#define CJSON_PUBLIC(type)   type CJSON_STDCALL
659750e409Sopenharmony_ci#elif defined(CJSON_EXPORT_SYMBOLS)
669750e409Sopenharmony_ci#define CJSON_PUBLIC(type)   __declspec(dllexport) type CJSON_STDCALL
679750e409Sopenharmony_ci#elif defined(CJSON_IMPORT_SYMBOLS)
689750e409Sopenharmony_ci#define CJSON_PUBLIC(type)   __declspec(dllimport) type CJSON_STDCALL
699750e409Sopenharmony_ci#endif
709750e409Sopenharmony_ci#else /* !__WINDOWS__ */
719750e409Sopenharmony_ci#define CJSON_CDECL
729750e409Sopenharmony_ci#define CJSON_STDCALL
739750e409Sopenharmony_ci
749750e409Sopenharmony_ci#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
759750e409Sopenharmony_ci#define CJSON_PUBLIC(type)   __attribute__((visibility("default"))) type
769750e409Sopenharmony_ci#else
779750e409Sopenharmony_ci#define CJSON_PUBLIC(type) type
789750e409Sopenharmony_ci#endif
799750e409Sopenharmony_ci#endif
809750e409Sopenharmony_ci
819750e409Sopenharmony_ci/* project version */
829750e409Sopenharmony_ci#define CJSON_VERSION_MAJOR 1
839750e409Sopenharmony_ci#define CJSON_VERSION_MINOR 7
849750e409Sopenharmony_ci#define CJSON_VERSION_PATCH 17
859750e409Sopenharmony_ci
869750e409Sopenharmony_ci#include <stddef.h>
879750e409Sopenharmony_ci
889750e409Sopenharmony_ci/* use int64 if it is enabled and supported */
899750e409Sopenharmony_ci#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && defined(ENABLE_INT64)
909750e409Sopenharmony_ci#define __CJSON_USE_INT64
919750e409Sopenharmony_ci#endif
929750e409Sopenharmony_ci
939750e409Sopenharmony_ci/* cJSON Types: */
949750e409Sopenharmony_ci#define cJSON_Invalid (0)
959750e409Sopenharmony_ci#define cJSON_False  (1 << 0)
969750e409Sopenharmony_ci#define cJSON_True   (1 << 1)
979750e409Sopenharmony_ci#define cJSON_NULL   (1 << 2)
989750e409Sopenharmony_ci#define cJSON_Number (1 << 3)
999750e409Sopenharmony_ci#define cJSON_String (1 << 4)
1009750e409Sopenharmony_ci#define cJSON_Array  (1 << 5)
1019750e409Sopenharmony_ci#define cJSON_Object (1 << 6)
1029750e409Sopenharmony_ci#define cJSON_Raw    (1 << 7) /* raw json */
1039750e409Sopenharmony_ci
1049750e409Sopenharmony_ci#define cJSON_IsReference 256
1059750e409Sopenharmony_ci#define cJSON_StringIsConst 512
1069750e409Sopenharmony_ci#ifdef __CJSON_USE_INT64
1079750e409Sopenharmony_ci#define cJSON_IsInt64 1024
1089750e409Sopenharmony_ci#endif
1099750e409Sopenharmony_ci
1109750e409Sopenharmony_ci/* The cJSON structure: */
1119750e409Sopenharmony_citypedef struct cJSON
1129750e409Sopenharmony_ci{
1139750e409Sopenharmony_ci    /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
1149750e409Sopenharmony_ci    struct cJSON *next;
1159750e409Sopenharmony_ci    struct cJSON *prev;
1169750e409Sopenharmony_ci    /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
1179750e409Sopenharmony_ci    struct cJSON *child;
1189750e409Sopenharmony_ci
1199750e409Sopenharmony_ci    /* The type of the item, as above. */
1209750e409Sopenharmony_ci    int type;
1219750e409Sopenharmony_ci
1229750e409Sopenharmony_ci    /* The item's string, if type==cJSON_String  and type == cJSON_Raw */
1239750e409Sopenharmony_ci    char *valuestring;
1249750e409Sopenharmony_ci#ifdef __CJSON_USE_INT64
1259750e409Sopenharmony_ci    /* use long long if int64 is enabled */
1269750e409Sopenharmony_ci    long long valueint;
1279750e409Sopenharmony_ci#else
1289750e409Sopenharmony_ci    /* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
1299750e409Sopenharmony_ci    int valueint;
1309750e409Sopenharmony_ci#endif /* __CJSON_USE_INT64 */
1319750e409Sopenharmony_ci    /* The item's number, if type==cJSON_Number */
1329750e409Sopenharmony_ci    double valuedouble;
1339750e409Sopenharmony_ci
1349750e409Sopenharmony_ci    /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
1359750e409Sopenharmony_ci    char *string;
1369750e409Sopenharmony_ci} cJSON;
1379750e409Sopenharmony_ci
1389750e409Sopenharmony_citypedef struct cJSON_Hooks
1399750e409Sopenharmony_ci{
1409750e409Sopenharmony_ci      /* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
1419750e409Sopenharmony_ci      void *(CJSON_CDECL *malloc_fn)(size_t sz);
1429750e409Sopenharmony_ci      void (CJSON_CDECL *free_fn)(void *ptr);
1439750e409Sopenharmony_ci} cJSON_Hooks;
1449750e409Sopenharmony_ci
1459750e409Sopenharmony_citypedef int cJSON_bool;
1469750e409Sopenharmony_ci
1479750e409Sopenharmony_ci/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
1489750e409Sopenharmony_ci * This is to prevent stack overflows. */
1499750e409Sopenharmony_ci#ifndef CJSON_NESTING_LIMIT
1509750e409Sopenharmony_ci#define CJSON_NESTING_LIMIT 1000
1519750e409Sopenharmony_ci#endif
1529750e409Sopenharmony_ci
1539750e409Sopenharmony_ci/* returns the version of cJSON as a string */
1549750e409Sopenharmony_ciCJSON_PUBLIC(const char*) cJSON_Version(void);
1559750e409Sopenharmony_ci
1569750e409Sopenharmony_ci/* Supply malloc, realloc and free functions to cJSON */
1579750e409Sopenharmony_ciCJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
1589750e409Sopenharmony_ci
1599750e409Sopenharmony_ci/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
1609750e409Sopenharmony_ci/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
1619750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
1629750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length);
1639750e409Sopenharmony_ci/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
1649750e409Sopenharmony_ci/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
1659750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
1669750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated);
1679750e409Sopenharmony_ci
1689750e409Sopenharmony_ci/* Render a cJSON entity to text for transfer/storage. */
1699750e409Sopenharmony_ciCJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
1709750e409Sopenharmony_ci/* Render a cJSON entity to text for transfer/storage without any formatting. */
1719750e409Sopenharmony_ciCJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
1729750e409Sopenharmony_ci/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
1739750e409Sopenharmony_ciCJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
1749750e409Sopenharmony_ci/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
1759750e409Sopenharmony_ci/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
1769750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
1779750e409Sopenharmony_ci/* Delete a cJSON entity and all subentities. */
1789750e409Sopenharmony_ciCJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
1799750e409Sopenharmony_ci
1809750e409Sopenharmony_ci/* Returns the number of items in an array (or object). */
1819750e409Sopenharmony_ciCJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
1829750e409Sopenharmony_ci/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
1839750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
1849750e409Sopenharmony_ci/* Get item "string" from object. Case insensitive. */
1859750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
1869750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
1879750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
1889750e409Sopenharmony_ci/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
1899750e409Sopenharmony_ciCJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
1909750e409Sopenharmony_ci
1919750e409Sopenharmony_ci/* Check item type and return its value */
1929750e409Sopenharmony_ciCJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
1939750e409Sopenharmony_ci#ifdef __CJSON_USE_INT64
1949750e409Sopenharmony_ciCJSON_PUBLIC(long long *) cJSON_GetInt64NumberValue(cJSON * const item);
1959750e409Sopenharmony_ci#endif
1969750e409Sopenharmony_ciCJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item);
1979750e409Sopenharmony_ci
1989750e409Sopenharmony_ci/* These functions check the type of an item */
1999750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
2009750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
2019750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
2029750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
2039750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
2049750e409Sopenharmony_ci#ifdef __CJSON_USE_INT64
2059750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_IsInt64Number(const cJSON * const item);
2069750e409Sopenharmony_ci#endif
2079750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
2089750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
2099750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
2109750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
2119750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
2129750e409Sopenharmony_ci
2139750e409Sopenharmony_ci/* These calls create a cJSON item of the appropriate type. */
2149750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
2159750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
2169750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
2179750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
2189750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
2199750e409Sopenharmony_ci#ifdef __CJSON_USE_INT64
2209750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateInt64Number(long long integer);
2219750e409Sopenharmony_ci#endif
2229750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
2239750e409Sopenharmony_ci/* raw json */
2249750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
2259750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
2269750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
2279750e409Sopenharmony_ci
2289750e409Sopenharmony_ci/* Create a string where valuestring references a string so
2299750e409Sopenharmony_ci * it will not be freed by cJSON_Delete */
2309750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
2319750e409Sopenharmony_ci/* Create an object/array that only references it's elements so
2329750e409Sopenharmony_ci * they will not be freed by cJSON_Delete */
2339750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
2349750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
2359750e409Sopenharmony_ci
2369750e409Sopenharmony_ci/* These utilities create an Array of count items.
2379750e409Sopenharmony_ci * The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/
2389750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
2399750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
2409750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
2419750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count);
2429750e409Sopenharmony_ci
2439750e409Sopenharmony_ci/* Append item to the specified array/object. */
2449750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
2459750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
2469750e409Sopenharmony_ci/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
2479750e409Sopenharmony_ci * WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
2489750e409Sopenharmony_ci * writing to `item->string` */
2499750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
2509750e409Sopenharmony_ci/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
2519750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
2529750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
2539750e409Sopenharmony_ci
2549750e409Sopenharmony_ci/* Remove/Detach items from Arrays/Objects. */
2559750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
2569750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
2579750e409Sopenharmony_ciCJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
2589750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
2599750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
2609750e409Sopenharmony_ciCJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
2619750e409Sopenharmony_ciCJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
2629750e409Sopenharmony_ci
2639750e409Sopenharmony_ci/* Update array items. */
2649750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
2659750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
2669750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
2679750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
2689750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
2699750e409Sopenharmony_ci
2709750e409Sopenharmony_ci/* Duplicate a cJSON item */
2719750e409Sopenharmony_ciCJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
2729750e409Sopenharmony_ci/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
2739750e409Sopenharmony_ci * need to be released. With recurse!=0, it will duplicate any children connected to the item.
2749750e409Sopenharmony_ci * The item->next and ->prev pointers are always zero on return from Duplicate. */
2759750e409Sopenharmony_ci/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
2769750e409Sopenharmony_ci * case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
2779750e409Sopenharmony_ciCJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
2789750e409Sopenharmony_ci
2799750e409Sopenharmony_ci/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
2809750e409Sopenharmony_ci * The input pointer json cannot point to a read-only address area, such as a string constant,
2819750e409Sopenharmony_ci * but should point to a readable and writable address area. */
2829750e409Sopenharmony_ciCJSON_PUBLIC(void) cJSON_Minify(char *json);
2839750e409Sopenharmony_ci
2849750e409Sopenharmony_ci/* Helper functions for creating and adding items to an object at the same time.
2859750e409Sopenharmony_ci * They return the added item or NULL on failure. */
2869750e409Sopenharmony_ciCJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
2879750e409Sopenharmony_ciCJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
2889750e409Sopenharmony_ciCJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
2899750e409Sopenharmony_ciCJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
2909750e409Sopenharmony_ci#ifdef __CJSON_USE_INT64
2919750e409Sopenharmony_ciCJSON_PUBLIC(cJSON*) cJSON_AddInt64NumberToObject(cJSON * const object, const char * const name, const long long integer);
2929750e409Sopenharmony_ci#endif
2939750e409Sopenharmony_ciCJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
2949750e409Sopenharmony_ciCJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
2959750e409Sopenharmony_ciCJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
2969750e409Sopenharmony_ciCJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
2979750e409Sopenharmony_ciCJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
2989750e409Sopenharmony_ci
2999750e409Sopenharmony_ci#ifdef __CJSON_USE_INT64
3009750e409Sopenharmony_ciCJSON_PUBLIC(long long) cJSON_SetInt64NumberValue(cJSON * const object, const long long integer);
3019750e409Sopenharmony_ci#endif
3029750e409Sopenharmony_ci/* When assigning an integer value, it needs to be propagated to valuedouble too. */
3039750e409Sopenharmony_ci#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
3049750e409Sopenharmony_ci/* helper for the cJSON_SetNumberValue macro */
3059750e409Sopenharmony_ciCJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
3069750e409Sopenharmony_ci#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
3079750e409Sopenharmony_ci/* Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String */
3089750e409Sopenharmony_ciCJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
3099750e409Sopenharmony_ci
3109750e409Sopenharmony_ci/* If the object is not a boolean type this does nothing and returns cJSON_Invalid else it returns the new type*/
3119750e409Sopenharmony_ci#define cJSON_SetBoolValue(object, boolValue) ( \
3129750e409Sopenharmony_ci    (object != NULL && ((object)->type & (cJSON_False|cJSON_True))) ? \
3139750e409Sopenharmony_ci    (object)->type=((object)->type &(~(cJSON_False|cJSON_True)))|((boolValue)?cJSON_True:cJSON_False) : \
3149750e409Sopenharmony_ci    cJSON_Invalid\
3159750e409Sopenharmony_ci)
3169750e409Sopenharmony_ci
3179750e409Sopenharmony_ci/* Macro for iterating over an array or object */
3189750e409Sopenharmony_ci#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
3199750e409Sopenharmony_ci
3209750e409Sopenharmony_ci/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
3219750e409Sopenharmony_ciCJSON_PUBLIC(void *) cJSON_malloc(size_t size);
3229750e409Sopenharmony_ciCJSON_PUBLIC(void) cJSON_free(void *object);
3239750e409Sopenharmony_ci
3249750e409Sopenharmony_ci#ifdef __cplusplus
3259750e409Sopenharmony_ci}
3269750e409Sopenharmony_ci#endif
3279750e409Sopenharmony_ci
3289750e409Sopenharmony_ci#endif
329