From 6525d78d0a1d303c449762082942e71d3002b9ca Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 23 Mar 2018 11:26:36 +0100 Subject: [PATCH] json: Add a new function to cJSON. * src/cJSON.c (cJSON_CreateStringConvey): New. --- src/cJSON.c | 12 ++++++++++++ src/cJSON.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/cJSON.c b/src/cJSON.c index 1941d114..cf0cb132 100644 --- a/src/cJSON.c +++ b/src/cJSON.c @@ -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) { diff --git a/src/cJSON.h b/src/cJSON.h index 69c3056a..a200c318 100644 --- a/src/cJSON.h +++ b/src/cJSON.h @@ -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);