1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

Feature: Added function for writing boolean XML nodes as JSON

This commit is contained in:
Philipp Schafft 2020-10-07 16:54:42 +00:00
parent adef1ef38e
commit 9be721723c

View File

@ -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) {