elseif(*json=='\"'){*into++=*json++;while(*json&&*json!='\"'){if(*json=='\\')*into++=*json++;*into++=*json++;}*into++=*json++;}/* string literals, which are \" sensitive. */
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
*/
*/
#ifndef cJSON__h
#ifndef cJSON__h
#define cJSON__h
#define cJSON__h
#ifdef __cplusplus
#ifdef __cplusplus
extern"C"
extern"C"
{
{
#endif
#endif
/* cJSON Types: */
/* project version */
#define cJSON_False 0
#define CJSON_VERSION_MAJOR 1
#define cJSON_True 1
#define CJSON_VERSION_MINOR 5
#define cJSON_NULL 2
#define CJSON_VERSION_PATCH 9
#define cJSON_Number 3
#define cJSON_String 4
#include <stddef.h>
#define cJSON_Array 5
#define cJSON_Object 6
/* cJSON Types: */
#define cJSON_Invalid (0)
#define cJSON_IsReference 256
#define cJSON_False (1 << 0)
#define cJSON_StringIsConst 512
#define cJSON_True (1 << 1)
#define cJSON_NULL (1 << 2)
/* The cJSON structure: */
#define cJSON_Number (1 << 3)
typedefstructcJSON{
#define cJSON_String (1 << 4)
structcJSON*next,*prev;/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
#define cJSON_Array (1 << 5)
structcJSON*child;/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
#define cJSON_Object (1 << 6)
#define cJSON_Raw (1 << 7) /* raw json */
inttype;/* The type of the item, as above. */
#define cJSON_IsReference 256
char*valuestring;/* The item's string, if type==cJSON_String */
#define cJSON_StringIsConst 512
intvalueint;/* The item's number, if type==cJSON_Number */
doublevaluedouble;/* The item's number, if type==cJSON_Number */
/* The cJSON structure: */
typedefstructcJSON
char*string;/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
{
}cJSON;
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
structcJSON*next;
typedefstructcJSON_Hooks{
structcJSON*prev;
void*(*malloc_fn)(size_tsz);
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
void(*free_fn)(void*ptr);
structcJSON*child;
}cJSON_Hooks;
/* The type of the item, as above. */
/* Supply malloc, realloc and free functions to cJSON */
inttype;
externvoidcJSON_InitHooks(cJSON_Hooks*hooks);
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
char*valuestring;
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
externcJSON*cJSON_Parse(constchar*value);
intvalueint;
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
/* The item's number, if type==cJSON_Number */
externchar*cJSON_Print(cJSON*item);
doublevaluedouble;
/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
externchar*cJSON_PrintUnformatted(cJSON*item);
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
/* 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 */
/* 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. */
#define __WINDOWS__
externconstchar*cJSON_GetErrorPtr(void);
#endif
#ifdef __WINDOWS__
/* These calls create a cJSON item of the appropriate type. */
externcJSON*cJSON_CreateNull(void);
/* 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 2 define options:
externcJSON*cJSON_CreateTrue(void);
externcJSON*cJSON_CreateFalse(void);
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
externcJSON*cJSON_CreateBool(intb);
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
externcJSON*cJSON_CreateNumber(doublenum);
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
externcJSON*cJSON_CreateString(constchar*string);
externcJSON*cJSON_CreateArray(void);
For *nix builds that support visibility attribute, you can define similar behavior by
externcJSON*cJSON_CreateObject(void);
setting default visibility to hidden by adding
/* These utilities create an Array of count items. */
externvoidcJSON_AddItemToObjectCS(cJSON*object,constchar*string,cJSON*item);/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object */
/* export symbols by default, this is necessary for copy pasting the C and header file */
/* 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. */
/* 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. */
/* 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(). */
/* 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 */
/* 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. */
/* 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. */