better json printing
This commit is contained in:
parent
fe91ba707d
commit
b82a8bae26
5 changed files with 33 additions and 28 deletions
|
|
@ -835,7 +835,7 @@ cli_notification_cb(int s, void *arg)
|
|||
if (clicon_xml_parse_string(&eventstr, &xt) < 0)
|
||||
goto done;
|
||||
if ((xn = xml_child_i(xt, 0)) != NULL){
|
||||
if (xml2json(stdout, xn, 0) < 0)
|
||||
if (xml2json(stdout, xn, 0, 1) < 0)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -439,13 +439,11 @@ show_conf_as_json(clicon_handle h,
|
|||
cg_var *arg)
|
||||
{
|
||||
cxobj *xt = NULL;
|
||||
cxobj *xc;
|
||||
int retval = -1;
|
||||
|
||||
if (show_conf_as(h, cvv, arg, &xt) < 0)
|
||||
goto done;
|
||||
xc = NULL; /* Dont print xt itself */
|
||||
xml2json(stdout, xt, 1);
|
||||
xml2json(stdout, xt, 1, 0);
|
||||
retval = 0;
|
||||
done:
|
||||
if (xt)
|
||||
|
|
|
|||
|
|
@ -180,17 +180,10 @@ api_data_get(clicon_handle h,
|
|||
|
||||
FCGX_FPrintF(r->out, "Content-Type: application/yang.data+xml\r\n");
|
||||
FCGX_FPrintF(r->out, "\r\n");
|
||||
#if 0
|
||||
/* Iterate over result */
|
||||
if (xpath_vec(xt, cbuf_get(path1), &vec, &veclen) < 0)
|
||||
goto done;
|
||||
#endif
|
||||
if ((cbx = cbuf_new()) == NULL)
|
||||
goto done;
|
||||
cprintf(cbx, "{\n");
|
||||
if (xml2json_cbuf(cbx, xt, 1) < 0)
|
||||
if (xml2json_cbuf(cbx, xt, 1, 0) < 0)
|
||||
goto done;
|
||||
cprintf(cbx, "}");
|
||||
FCGX_FPrintF(r->out, "%s\r\n", cbuf_get(cbx));
|
||||
retval = 0;
|
||||
done:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue