Public API

Structures

cJSONThe cJSON structure:
cJSON_Hooks
error
internal_hooks
parse_buffer
printbuffer

Functions

cJSON_AddArrayToObject

Mentioned in

cJSON_AddBoolToObject
cJSON_AddFalseToObject
cJSON_AddItemReferenceToArrayAppend reference to item to the specified array/object
cJSON_AddItemReferenceToObject
cJSON_AddItemToArrayAppend item to the specified array/object.
cJSON_AddItemToObject

Mentioned in

cJSON_AddItemToObjectCSUse this when string is definitely const (i.e
cJSON_AddNullToObjectHelper functions for creating and adding items to an object at the same time
cJSON_AddNumberToObject

Mentioned in

cJSON_AddObjectToObject
cJSON_AddRawToObject
cJSON_AddStringToObject

Mentioned in

cJSON_AddTrueToObject
cJSON_CompareDuplicate will create a new, identical cJSON item to the one you pass, in new memory that will need to be released
cJSON_CreateArray

Mentioned in

cJSON_CreateArrayReference

Mentioned in

cJSON_CreateBool

Mentioned in

cJSON_CreateDoubleArray
cJSON_CreateFalse

Mentioned in

cJSON_CreateFloatArray
cJSON_CreateIntArrayThese utilities create an Array of count items
cJSON_CreateNullThese calls create a cJSON item of the appropriate type.
cJSON_CreateNumber

Mentioned in

cJSON_CreateObject

Mentioned in

cJSON_CreateObjectReferenceCreate an object/array that only references it's elements so they will not be freed by cJSON_Delete
cJSON_CreateRawraw json
cJSON_CreateString

Mentioned in

cJSON_CreateStringArray
cJSON_CreateStringReferenceCreate a string where valuestring references a string so it will not be freed by cJSON_Delete
cJSON_CreateTrue

Mentioned in

cJSON_DeleteDelete a cJSON entity and all subentities.
cJSON_DeleteItemFromArray

Mentioned in

cJSON_DeleteItemFromObject
cJSON_DeleteItemFromObjectCaseSensitive

Mentioned in

cJSON_DetachItemFromArray

Mentioned in

cJSON_DetachItemFromObject
cJSON_DetachItemFromObjectCaseSensitive

Mentioned in

cJSON_DetachItemViaPointerRemove/Detach items from Arrays/Objects.
cJSON_DuplicateDuplicate a cJSON item
cJSON_free

Mentioned in

cJSON_GetArrayItemRetrieve item number "index" from array "array"
cJSON_GetArraySizeReturns the number of items in an array (or object).
cJSON_GetErrorPtrFor analysing failed parses
cJSON_GetNumberValue

Mentioned in

cJSON_GetObjectItemGet item "string" from object
cJSON_GetObjectItemCaseSensitive

Mentioned in

cJSON_GetStringValueCheck item type and return its value
cJSON_HasObjectItem
cJSON_InitHooksSupply malloc, realloc and free functions to cJSON
cJSON_InsertItemInArrayUpdate array items.
cJSON_IsArray

Mentioned in

cJSON_IsBool

Mentioned in

cJSON_IsFalse

Mentioned in

cJSON_IsInvalidThese functions check the type of an item
cJSON_IsNull

Mentioned in

cJSON_IsNumber

Mentioned in

cJSON_IsObject

Mentioned in

cJSON_IsRaw

Mentioned in

cJSON_IsString

Mentioned in

cJSON_IsTrue

Mentioned in

cJSON_mallocmalloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks
cJSON_MinifyMinify a strings, remove blank characters(such as ' ', '\t', '\r', ' ') from strings
cJSON_ParseMemory 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)
cJSON_ParseWithLength

Mentioned in

cJSON_ParseWithLengthOptsParse an object - create a new root, and populate.
cJSON_ParseWithOptsParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed
cJSON_PrintRender a cJSON entity to text for transfer/storage.
cJSON_PrintBufferedRender a cJSON entity to text using a buffered strategy
cJSON_PrintPreallocatedRender a cJSON entity to text using a buffer already allocated in memory with given length
cJSON_PrintUnformattedRender a cJSON entity to text for transfer/storage without any formatting.
cJSON_ReplaceItemInArray

Mentioned in

cJSON_ReplaceItemInObject

Mentioned in

cJSON_ReplaceItemInObjectCaseSensitive

Mentioned in

cJSON_ReplaceItemViaPointer

Mentioned in

cJSON_SetNumberHelperhelper for the cJSON_SetNumberValue macro
cJSON_SetValuestringChange the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String
cJSON_Versionreturns the version of cJSON as a string

Defines

Defines (cJSON.c)

true ((cJSON_bool)1)

cJSON JSON parser in C. disable warnings about old C89 functions in MSVC define our own boolean type

false ((cJSON_bool)0)

isinf(d)
(isnan((d - d)) && !isnan(d))

define isnan and isinf for ANSI C, if in C99 or above, isnan and isinf has been defined in math.h

isnan(d)
(d != d)

NAN 0.0/0.0

Mentioned in:

internal_malloc malloc

internal_free free

internal_realloc realloc

static_strlen(string_literal)
(sizeof(string_literal) - sizeof(""))

strlen of character literals resolved at compile time

can_read(buffer,size)
((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))

check if the given size is left to read in a given parse buffer (starting with 1)

can_access_at_index(buffer,index)
((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))

check if the buffer can be accessed at the given index (starting with 0)

cannot_access_at_index(buffer,index)
(!can_access_at_index(buffer, index))

buffer_at_offset(buffer)
((buffer)->content + (buffer)->offset)

get a pointer to the buffer at the position

cjson_min(a,b)
(((a) < (b)) ? (a) : (b))

Defines (cJSON.h)

CJSON_CDECL

CJSON_STDCALL

CJSON_PUBLIC(type)
type

CJSON_VERSION_MAJOR 1

project version

CJSON_VERSION_MINOR 7

CJSON_VERSION_PATCH 14

cJSON_Invalid (0)

cJSON Types:

Mentioned in:

Getting Started / Data Structure

Changelog / 1.3.0 (Feb 17, 2017)

cJSON_False (1 << 0)

Mentioned in:

cJSON_True (1 << 1)

Mentioned in:

cJSON_NULL (1 << 2)

Mentioned in:

cJSON_Number (1 << 3)

Mentioned in:

cJSON_String (1 << 4)

Mentioned in:

cJSON_Array (1 << 5)

Mentioned in:

cJSON_Object (1 << 6)

Mentioned in:

cJSON_Raw (1 << 7) /* raw json */

Mentioned in:

cJSON_IsReference 256

Mentioned in:

cJSON_StringIsConst 512

Mentioned in:

CJSON_NESTING_LIMIT 1000

Limits how deeply nested arrays/objects can be before cJSON rejects to parse them. This is to prevent stack overflows.

Mentioned in:

Getting Started / Deep Nesting Of Arrays And Objects

Changelog / Fixes:

cJSON_SetIntValue(object,number)
((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))

When assigning an integer value, it needs to be propagated to valuedouble too.

cJSON_SetNumberValue(object,number)
((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))

Mentioned in:

cJSON_ArrayForEach(element,array)
for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)

Macro for iterating over an array or object

Mentioned in:

Getting Started / Arrays

Getting Started / Objects

Getting Started / Parsing

Changelog / Features

Typedefs

Typedefs (cJSON.h)

typedef int cJSON_bool

Mentioned in:

Variables

Variables (cJSON.c)

error global_error = { NULL, 0 }

internal_hooks global_hooks = { malloc , free , realloc }






Add Discussion as Guest

Log in