From 303f4a35a8e2a0167c2c86a8febcb804a9c18093 Mon Sep 17 00:00:00 2001 From: Olof Hagsand Date: Thu, 6 Oct 2016 20:58:41 +0200 Subject: [PATCH] json escape etc --- apps/restconf/restconf_main.c | 3 ++- lib/src/clixon_json.c | 36 ++++++++++++++++++++++++++++++++--- lib/src/clixon_xml_db.c | 12 +++--------- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/apps/restconf/restconf_main.c b/apps/restconf/restconf_main.c index 4bac2d87..1e42c619 100644 --- a/apps/restconf/restconf_main.c +++ b/apps/restconf/restconf_main.c @@ -218,7 +218,7 @@ api_data_get(clicon_handle h, FCGX_FPrintF(r->out, "\r\n"); if (xml2json_cbuf_vec(cbx, vec, veclen, 0) < 0) goto done; - FCGX_FPrintF(r->out, "[%s]", cbuf_get(cbx)); + FCGX_FPrintF(r->out, "%s", cbuf_get(cbx)); FCGX_FPrintF(r->out, "\r\n\r\n"); retval = 0; done: @@ -341,6 +341,7 @@ api_data_put(clicon_handle h, FCGX_SetExitStatus(201, r->out); /* Created */ FCGX_FPrintF(r->out, "Content-Type: text/plain\r\n"); FCGX_FPrintF(r->out, "\r\n"); + retval = 0; done: clicon_debug(1, "%s retval:%d", __FUNCTION__, retval); if (xdata) diff --git a/lib/src/clixon_json.c b/lib/src/clixon_json.c index d582c255..1bd064d4 100644 --- a/lib/src/clixon_json.c +++ b/lib/src/clixon_json.c @@ -160,6 +160,32 @@ array_eval(cxobj *xprev, return array; } +char * +json_escape(char *str) +{ + int i, j; + char *snew; + + j = 0; + for (i=0;iys_keyword){ case Y_LEAF_LIST: - // val2 = vec[i]; /* No */ + /* For leaf-list 'keys' is value, see 3.5.1 in restconf draft */ val2 = keys; - if (i>=nvec){ - clicon_err(OE_XML, errno, "Leaf-list %s without argument", name); - goto done; - } - // i++; - cprintf(ckey, "/%s", val2); + cprintf(ckey, "/%s", keys); break; case Y_LIST: if ((ykey = yang_find((yang_node*)y, Y_KEY, NULL)) == NULL){