Add cJSON_Create{Array,Object}Reference
This commit is contained in:
21
cJSON.c
21
cJSON.c
@@ -2210,6 +2210,27 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string)
|
||||
return item;
|
||||
}
|
||||
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child)
|
||||
{
|
||||
cJSON *item = cJSON_New_Item(&global_hooks);
|
||||
if (item != NULL) {
|
||||
item->type = cJSON_Object | cJSON_IsReference;
|
||||
item->child = (cJSON*)cast_away_const(child);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) {
|
||||
cJSON *item = cJSON_New_Item(&global_hooks);
|
||||
if (item != NULL) {
|
||||
item->type = cJSON_Array | cJSON_IsReference;
|
||||
item->child = (cJSON*)cast_away_const(child);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw)
|
||||
{
|
||||
cJSON *item = cJSON_New_Item(&global_hooks);
|
||||
|
||||
Reference in New Issue
Block a user