TuyaOS
cJSON.h
1/*
2 Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21*/
22
23#ifndef cJSON__h
24#define cJSON__h
25
26#ifdef __cplusplus
27extern "C"
28{
29#endif
30
31#include "ty_cJSON.h"
32
33/* project version */
34#define CJSON_VERSION_MAJOR 1
35#define CJSON_VERSION_MINOR 7
36#define CJSON_VERSION_PATCH 15
37
38#include <stddef.h>
39
40/* cJSON Types: */
41#define cJSON_Invalid ty_cJSON_Invalid
42#define cJSON_False ty_cJSON_False
43#define cJSON_True ty_cJSON_True
44#define cJSON_NULL ty_cJSON_NULL
45#define cJSON_Number ty_cJSON_Number
46#define cJSON_String ty_cJSON_String
47#define cJSON_Array ty_cJSON_Array
48#define cJSON_Object ty_cJSON_Object
49#define cJSON_Raw ty_cJSON_Raw
50
51#define cJSON_IsReference ty_cJSON_IsReference
52#define cJSON_StringIsConst ty_cJSON_StringIsConst
53
54/* The ty_cJSON structure: */
55/* The cJSON structure: */
56typedef struct ty_cJSON cJSON;
57
58typedef struct ty_cJSON_Hooks cJSON_Hooks;
59
60#define cJSON_bool ty_cJSON_bool
61
62/* returns the version of ty_cJSON as a string */
63#define cJSON_Version ty_cJSON_Version
64
65/* Supply malloc, realloc and free functions to ty_cJSON */
66#define cJSON_InitHooks ty_cJSON_InitHooks
67
68/* Memory Management: the caller is always responsible to free the results from all variants of ty_cJSON_Parse (with ty_cJSON_Delete) and ty_cJSON_Print (with stdlib free, ty_cJSON_Hooks.free_fn, or ty_cJSON_free as appropriate). The exception is ty_cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
69/* Supply a block of JSON, and this returns a ty_cJSON object you can interrogate. */
70#define cJSON_Parse ty_cJSON_Parse
71#define cJSON_ParseWithLength ty_cJSON_ParseWithLength
72/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
73/* 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 ty_cJSON_GetErrorPtr(). */
74#define cJSON_ParseWithOpts ty_cJSON_ParseWithOpts
75#define cJSON_ParseWithLengthOpts ty_cJSON_ParseWithLengthOpts
76
77/* Render a ty_cJSON entity to text for transfer/storage. */
78#define cJSON_Print ty_cJSON_Print
79/* Render a ty_cJSON entity to text for transfer/storage without any formatting. */
80#define cJSON_PrintUnformatted ty_cJSON_PrintUnformatted
81/* Render a ty_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 */
82#define cJSON_PrintBuffered ty_cJSON_PrintBuffered
83/* Render a ty_cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
84/* NOTE: ty_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 */
85#define cJSON_PrintPreallocated ty_cJSON_PrintPreallocated
86/* Delete a ty_cJSON entity and all subentities. */
87#define cJSON_Delete ty_cJSON_Delete
88
89/* Returns the number of items in an array (or object). */
90#define cJSON_GetArraySize ty_cJSON_GetArraySize
91/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
92#define cJSON_GetArrayItem ty_cJSON_GetArrayItem
93/* Get item "string" from object. Case insensitive. */
94#define cJSON_GetObjectItem ty_cJSON_GetObjectItem
95#define cJSON_GetObjectItemCaseSensitive ty_cJSON_GetObjectItemCaseSensitive
96#define cJSON_HasObjectItem ty_cJSON_HasObjectItem
97/* 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 ty_cJSON_Parse() returns 0. 0 when ty_cJSON_Parse() succeeds. */
98#define cJSON_GetErrorPtr ty_cJSON_GetErrorPtr
99
100/* Check item type and return its value */
101#define cJSON_GetStringValue ty_cJSON_GetStringValue
102#define cJSON_GetNumberValue ty_cJSON_GetNumberValue
103
104/* These functions check the type of an item */
105#define cJSON_IsInvalid ty_cJSON_IsInvalid
106#define cJSON_IsFalse ty_cJSON_IsFalse
107#define cJSON_IsTrue ty_cJSON_IsTrue
108#define cJSON_IsBool ty_cJSON_IsBool
109#define cJSON_IsNull ty_cJSON_IsNull
110#define cJSON_IsNumber ty_cJSON_IsNumber
111#define cJSON_IsString ty_cJSON_IsString
112#define cJSON_IsArray ty_cJSON_IsArray
113#define cJSON_IsObject ty_cJSON_IsObject
114#define cJSON_IsRaw ty_cJSON_IsRaw
115
116/* These calls create a ty_cJSON item of the appropriate type. */
117#define cJSON_CreateNull ty_cJSON_CreateNull
118#define cJSON_CreateTrue ty_cJSON_CreateTrue
119#define cJSON_CreateFalse ty_cJSON_CreateFalse
120#define cJSON_CreateBool ty_cJSON_CreateBool
121#define cJSON_CreateNumber ty_cJSON_CreateNumber
122#define cJSON_CreateString ty_cJSON_CreateString
123/* raw json */
124#define cJSON_CreateRaw ty_cJSON_CreateRaw
125#define cJSON_CreateArray ty_cJSON_CreateArray
126#define cJSON_CreateObject ty_cJSON_CreateObject
127
128/* Create a string where valuestring references a string so
129 * it will not be freed by ty_cJSON_Delete */
130#define cJSON_CreateStringReference ty_cJSON_CreateStringReference
131/* Create an object/array that only references it's elements so
132 * they will not be freed by ty_cJSON_Delete */
133#define cJSON_CreateObjectReference ty_cJSON_CreateObjectReference
134#define cJSON_CreateArrayReference ty_cJSON_CreateArrayReference
135
136/* These utilities create an Array of count items.
137 * The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/
138#define cJSON_CreateIntArray ty_cJSON_CreateIntArray
139#define cJSON_CreateFloatArray ty_cJSON_CreateFloatArray
140#define cJSON_CreateDoubleArray ty_cJSON_CreateDoubleArray
141#define cJSON_CreateStringArray ty_cJSON_CreateStringArray
142
143/* Append item to the specified array/object. */
144#define cJSON_AddItemToArray ty_cJSON_AddItemToArray
145#define cJSON_AddItemToObject ty_cJSON_AddItemToObject
146/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the ty_cJSON object.
147 * WARNING: When this function was used, make sure to always check that (item->type & ty_cJSON_StringIsConst) is zero before
148 * writing to `item->string` */
149#define cJSON_AddItemToObjectCS ty_cJSON_AddItemToObjectCS
150/* Append reference to item to the specified array/object. Use this when you want to add an existing ty_cJSON to a new ty_cJSON, but don't want to corrupt your existing ty_cJSON. */
151#define cJSON_AddItemReferenceToArray ty_cJSON_AddItemReferenceToArray
152#define cJSON_AddItemReferenceToObject ty_cJSON_AddItemReferenceToObject
153
154/* Remove/Detach items from Arrays/Objects. */
155#define cJSON_DetachItemViaPointer ty_cJSON_DetachItemViaPointer
156#define cJSON_DetachItemFromArray ty_cJSON_DetachItemFromArray
157#define cJSON_DeleteItemFromArray ty_cJSON_DeleteItemFromArray
158#define cJSON_DetachItemFromObject ty_cJSON_DetachItemFromObject
159#define cJSON_DetachItemFromObjectCaseSensitive ty_cJSON_DetachItemFromObjectCaseSensitive
160#define cJSON_DeleteItemFromObject ty_cJSON_DeleteItemFromObject
161#define cJSON_DeleteItemFromObjectCaseSensitive ty_cJSON_DeleteItemFromObjectCaseSensitive
162
163/* Update array items. */
164#define cJSON_InsertItemInArray ty_cJSON_InsertItemInArray
165#define cJSON_ReplaceItemViaPointer ty_cJSON_ReplaceItemViaPointer
166#define cJSON_ReplaceItemInArray ty_cJSON_ReplaceItemInArray
167#define cJSON_ReplaceItemInObject ty_cJSON_ReplaceItemInObject
168#define cJSON_ReplaceItemInObjectCaseSensitive ty_cJSON_ReplaceItemInObjectCaseSensitive
169
170/* Duplicate a ty_cJSON item */
171#define cJSON_Duplicate ty_cJSON_Duplicate
172/* Duplicate will create a new, identical ty_cJSON item to the one you pass, in new memory that will
173 * need to be released. With recurse!=0, it will duplicate any children connected to the item.
174 * The item->next and ->prev pointers are always zero on return from Duplicate. */
175/* Recursively compare two ty_cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
176 * case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
177#define cJSON_Compare ty_cJSON_Compare
178
179/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
180 * The input pointer json cannot point to a read-only address area, such as a string constant,
181 * but should point to a readable and writable address area. */
182#define cJSON_Minify ty_cJSON_Minify
183
184/* Helper functions for creating and adding items to an object at the same time.
185 * They return the added item or NULL on failure. */
186#define cJSON_AddNullToObject ty_cJSON_AddNullToObject
187#define cJSON_AddTrueToObject ty_cJSON_AddTrueToObject
188#define cJSON_AddFalseToObject ty_cJSON_AddFalseToObject
189#define cJSON_AddBoolToObject ty_cJSON_AddBoolToObject
190#define cJSON_AddNumberToObject ty_cJSON_AddNumberToObject
191#define cJSON_AddStringToObject ty_cJSON_AddStringToObject
192#define cJSON_AddRawToObject ty_cJSON_AddRawToObject
193#define cJSON_AddObjectToObject ty_cJSON_AddObjectToObject
194#define cJSON_AddArrayToObject ty_cJSON_AddArrayToObject
195
196/* When assigning an integer value, it needs to be propagated to valuedouble too. */
197#define cJSON_SetIntValue ty_cJSON_SetIntValue
198/* helper for the ty_cJSON_SetNumberValue macro */
199#define cJSON_SetNumberHelper ty_cJSON_SetNumberHelper
200#define cJSON_SetNumberValue ty_cJSON_SetNumberValue
201/* Change the valuestring of a ty_cJSON_String object, only takes effect when type of object is ty_cJSON_String */
202#define cJSON_SetValuestring ty_cJSON_SetValuestring
203
204/* Macro for iterating over an array or object */
205#define cJSON_ArrayForEach ty_cJSON_ArrayForEach
206
207/* malloc/free objects using the malloc/free functions that have been set with ty_cJSON_InitHooks */
208#define cJSON_malloc ty_cJSON_malloc
209#define cJSON_free ty_cJSON_free
210
211#ifdef __cplusplus
212}
213#endif
214
215#endif
Definition: ty_cJSON.h:126
Definition: ty_cJSON.h:104