Fixed: [Returning a string while Querying leaf-list for single entry](https://github.com/clicon/clixon/issues/326)

This commit is contained in:
Olof hagsand 2022-05-12 12:04:13 +02:00
parent 7065d6f760
commit 0c81b66ef3
6 changed files with 66 additions and 8 deletions

View file

@ -337,12 +337,21 @@ main(int argc,
}
/* 4. Output data (xml/json) */
if (output){
#if 0
if (jsonout)
xml2json_cbuf(cb, xt, pretty); /* print json */
else
clicon_xml2cbuf(cb, xt, 0, pretty, -1); /* print xml */
#else
xc = NULL;
while ((xc = xml_child_each(xt, xc, -1)) != NULL)
/* XXX This is troublesome for JSON top-level lists */
while ((xc = xml_child_each(xt, xc, -1)) != NULL){
if (jsonout)
xml2json_cbuf(cb, xc, pretty); /* print xml */
xml2json_cbuf(cb, xc, pretty); /* print json */
else
clicon_xml2cbuf(cb, xc, 0, pretty, -1); /* print xml */
}
#endif
fprintf(stdout, "%s", cbuf_get(cb));
fflush(stdout);
}