json: Add a new function to cJSON.

* src/cJSON.c (cJSON_CreateStringConvey): New.
This commit is contained in:
Werner Koch 2018-03-23 11:26:36 +01:00
parent e14f1f687f
commit 6525d78d0a
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 13 additions and 0 deletions

View File

@ -1199,6 +1199,18 @@ cJSON_CreateString (const char *string)
return item;
}
cJSON *
cJSON_CreateStringConvey (char *string)
{
cJSON *item = cJSON_New_Item ();
if (item)
{
item->type = cJSON_String;
item->valuestring = string;
}
return item;
}
cJSON *
cJSON_CreateArray (void)
{

View File

@ -113,6 +113,7 @@ extern cJSON *cJSON_CreateFalse(void);
extern cJSON *cJSON_CreateBool(int b);
extern cJSON *cJSON_CreateNumber(double num);
extern cJSON *cJSON_CreateString(const char *string);
extern cJSON *cJSON_CreateStringConvey (char *string);
extern cJSON *cJSON_CreateArray(void);
extern cJSON *cJSON_CreateObject(void);