diff --git a/apps/restconf/restconf_main.c b/apps/restconf/restconf_main.c
index 38ac35d7..b7f3a964 100644
--- a/apps/restconf/restconf_main.c
+++ b/apps/restconf/restconf_main.c
@@ -62,22 +62,23 @@
resource ([RFC6415]) */
#define RESTCONF_API_ROOT "/restconf/"
-/*! Generic REST GET method
- * @param[in] r Fastcgi request handle
- * @param[in] api_path According to restconf (Sec 3.5.1.1 in [draft])
- * @param[in] pcvec Vector of path ie DOCUMENT_URI element
+/*! Generic REST GET method
+ * According to restconf (Sec 3.5.1.1 in [draft])
+ * @param[in] h Clixon handle
+ * @param[in] r Fastcgi request handle
+ * @param[in] pcvec Vector of path ie DOCUMENT_URI element
* @param[in] pi Offset, where path starts
- * @param[in] qvec Vector of query string (QUERY_STRING)
- * @code
+ * @param[in] qvec Vector of query string (QUERY_STRING)
+ * @code
* curl -G http://localhost/restconf/data/interfaces/interface=eth0
- * @endcode
- * XXX: cant find a way to use Accept request field to choose Content-Type
- * I would like to support both xml and json.
- * Request may contain
- * Accept: application/yang.data+json,application/yang.data+xml
- * Response contains one of:
- * Content-Type: application/yang.data+xml
- * Content-Type: application/yang.data+json
+ * @endcode
+ * XXX: cant find a way to use Accept request field to choose Content-Type
+ * I would like to support both xml and json.
+ * Request may contain
+ * Accept: application/yang.data+json,application/yang.data+xml
+ * Response contains one of:
+ * Content-Type: application/yang.data+xml
+ * Content-Type: application/yang.data+json
* NOTE: If a retrieval request for a data resource representing a YANG leaf-
* list or list object identifies more than one instance, and XML
* encoding is used in the response, then an error response containing a
diff --git a/lib/src/clixon_json.c b/lib/src/clixon_json.c
index 373ccfa6..22443068 100644
--- a/lib/src/clixon_json.c
+++ b/lib/src/clixon_json.c
@@ -137,6 +137,7 @@ enum list_element_type{
LIST_MIDDLE,
LIST_LAST
};
+
static enum list_element_type
list_eval(cxobj *x)
{
@@ -179,11 +180,8 @@ list_eval(cxobj *x)
return list;
}
-
/*!
* @param[in] pretty set if the output should be pretty-printed
-
-
* List only if adjacent,
* ie 123 -> {"a":[1,2],"b":3}
* ie 132 -> {"a":1,"b":3,"a":2}
@@ -252,22 +250,29 @@ xml2json1_cbuf(cbuf *cb,
}
switch (list){
case LIST_NO:
- if (!tleaf(x))
+ if (!tleaf(x)){
if (pretty)
cprintf(cb, "%*s}\n",
(level*JSON_INDENT), "");
+ else
+ cprintf(cb, "}");
+ }
break;
case LIST_MIDDLE:
case LIST_FIRST:
if (pretty)
cprintf(cb, "\n%*s}",
(level*JSON_INDENT), "");
+ else
+ cprintf(cb, "}");
break;
case LIST_LAST:
if (!tleaf(x)){
if (pretty)
cprintf(cb, "\n%*s}\n",
(level*JSON_INDENT), "");
+ else
+ cprintf(cb, "}");
level--;
}
cprintf(cb, "%*s]%s",
@@ -309,15 +314,16 @@ xml2json_cbuf(cbuf *cb,
int pretty)
{
int retval = 1;
- int level = 0;
- int i;
- cxobj *xc;
+ int level = 1;
- for (i=0; i