From 9be721723cf449a79c66c70d3b45b7af63b5b72e Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Wed, 7 Oct 2020 16:54:42 +0000 Subject: [PATCH] Feature: Added function for writing boolean XML nodes as JSON --- src/xml2json.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/xml2json.c b/src/xml2json.c index ac9e014b..e234e7b4 100644 --- a/src/xml2json.c +++ b/src/xml2json.c @@ -19,6 +19,7 @@ #include "xml2json.h" #include "json.h" +#include "util.h" /* For XMLSTR() */ #include "cfgfile.h" @@ -108,6 +109,16 @@ static void handle_textchildnode(json_renderer_t *renderer, xmlDocPtr doc, xmlNo } } +static void handle_booleanchildnode(json_renderer_t *renderer, xmlDocPtr doc, xmlNodePtr node, xmlNodePtr parent, struct xml2json_cache *cache) +{ + xmlChar *value = xmlNodeListGetString(doc, node->xmlChildrenNode, 1); + if (value) { + json_renderer_write_key(renderer, (const char *)node->name, JSON_RENDERER_FLAGS_NONE); + json_renderer_write_boolean(renderer, util_str_to_bool((const char*)value)); + xmlFree(value); + } +} + static int handle_node_modules(json_renderer_t *renderer, xmlDocPtr doc, xmlNodePtr node, xmlNodePtr parent, struct xml2json_cache *cache) { if (node->type == XML_ELEMENT_NODE && strcmp((const char *)node->name, "modules") == 0) {