[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] libxl: Convert libxl__json_object_to_json() to json_object
commit 75fa670e582cdee7d8ac639d0cb9932b8867f740 Author: Anthony PERARD <anthony.perard@xxxxxxxxxx> AuthorDate: Mon Sep 29 14:07:53 2025 +0200 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Mon Oct 6 12:36:55 2025 +0100 libxl: Convert libxl__json_object_to_json() to json_object But keep the implementation done for YAJL. Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx> --- tools/libs/light/libxl_json.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/libs/light/libxl_json.c b/tools/libs/light/libxl_json.c index eeda9c301d..c76ae9f64a 100644 --- a/tools/libs/light/libxl_json.c +++ b/tools/libs/light/libxl_json.c @@ -104,10 +104,12 @@ typedef struct libxl__yajl_ctx { * YAJL Helper */ +#ifdef HAVE_LIBYAJL yajl_gen_status libxl__yajl_gen_asciiz(yajl_gen hand, const char *str) { return yajl_gen_string(hand, (const unsigned char *)str, strlen(str)); } +#endif #ifdef HAVE_LIBJSONC int libxl__enum_gen_jso(json_object **jso_r, const char *str) @@ -1527,6 +1529,29 @@ out: char *libxl__json_object_to_json(libxl__gc *gc, const libxl__json_object *args) { +#ifdef HAVE_LIBJSONC + const char *buf; + json_object *root; + char *ret = NULL; + int rc; + + if (!args) + return NULL; + + rc = libxl__json_object_to_json_object(gc, &root, args); + if (rc) + goto out; + + buf = json_object_to_json_string_ext(root, JSON_C_TO_STRING_PRETTY); + if (!buf) + goto out; + + ret = libxl__strdup(gc, buf); + +out: + json_object_put(root); + return ret; +#elif defined(HAVE_LIBYAJL) const unsigned char *buf; libxl_yajl_length len; yajl_gen_status s; @@ -1554,6 +1579,7 @@ char *libxl__json_object_to_json(libxl__gc *gc, out: yajl_gen_free(hand); return ret; +#endif } #ifdef HAVE_LIBJSONC -- generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |