StructcJSON
Index
Fields
Functions

StructcJSON

The cJSON structure:

Fields

next cJSON *
prev cJSON *
child cJSON *

next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem

type int

An array or object item will have a child pointer pointing to a chain of the items in the array/object.

valuestring char *

The type of the item, as above.

valueint int

The item's string, if type==cJSON_String

valuedouble double

The item's number, if type==cJSON_Number

string char *

The item's number, if type==cJSON_Number

Functions

void
cJSON_AddItemReferenceToArray ( cJSON * array,
cJSON * item )

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.

array
item
void
cJSON_AddItemReferenceToObject ( cJSON * object,
char const * string,
cJSON * item )
object
string
item
void
cJSON_AddItemToArray ( cJSON * array,
cJSON * item )

Append item to the specified array/object.

array
item
void
cJSON_AddItemToObject ( cJSON * object,
char const * string,
cJSON * item )
object
string
item
void
cJSON_AddItemToObjectCS ( cJSON * object,
char const * string,
cJSON * item )
object
string
item
void
cJSON_Delete ( cJSON * c )

Delete a cJSON entity and all subentities.

c
void
cJSON_DeleteItemFromArray ( cJSON * array,
int which )
array
which
void
cJSON_DeleteItemFromObject ( cJSON * object,
char const * string )
object
string
cJSON_DetachItemFromArray ( cJSON * array,
int which )

Remove/Detatch items from Arrays/Objects.

array
which
return
cJSON_DetachItemFromObject ( cJSON * object,
char const * string )
object
string
return
cJSON_Duplicate ( cJSON * item,
int recurse )

Duplicate a cJSON item

item
recurse
return
cJSON_GetArrayItem ( cJSON * array,
int item )

Retrieve item number "item" from array "array". Returns NULL if unsuccessful.

array
item
return
int
cJSON_GetArraySize ( cJSON * array )

Returns the number of items in an array (or object).

array
return
cJSON_GetObjectItem ( cJSON * object,
char const * string )

Get item "string" from object. Case insensitive.

object
string
return
void
cJSON_InsertItemInArray ( cJSON * array,
int which,
cJSON * newitem )

Update array items.

array
which
newitem
char *
cJSON_Print ( cJSON * item )

Render a cJSON entity to text for transfer/storage. Free the char* when finished.

item
return
char *
cJSON_PrintBuffered ( cJSON * item,
int prebuffer,
int fmt )

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

item
prebuffer
fmt
return
char *
cJSON_PrintUnformatted ( cJSON * item )

Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished.

item
return
void
cJSON_ReplaceItemInArray ( cJSON * array,
int which,
cJSON * newitem )

Shifts pre-existing items to the right.

array
which
newitem
void
cJSON_ReplaceItemInObject ( cJSON * object,
char const * string,
cJSON * newitem )
object
string
newitem