diff --git a/lib/src/clixon_json.c b/lib/src/clixon_json.c
index 9c87d9ef..2d988347 100644
--- a/lib/src/clixon_json.c
+++ b/lib/src/clixon_json.c
@@ -231,11 +231,7 @@ array_eval(cxobj *xprev,
else if (eqnext)
arraytype = FIRST_ARRAY;
else if ((ys = xml_spec(x)) != NULL) {
- if (yang_keyword_get(ys) == Y_LIST
-#if 0 /* XXX instead see special case in xml2json_encode_leafs */
- || yang_keyword_get(ys) == Y_LEAF_LIST
-#endif
- )
+ if (yang_keyword_get(ys) == Y_LIST || yang_keyword_get(ys) == Y_LEAF_LIST)
arraytype = SINGLE_ARRAY;
else
arraytype = NO_ARRAY;
@@ -601,12 +597,6 @@ xml2json_encode_leafs(cxobj *xb,
case CGV_UINT64:
case CGV_DEC64:
case CGV_BOOL:
-#if 1 /* Special case */
- if (yang_keyword_get(yp) == Y_LEAF_LIST
- && xml_child_nr_type(xml_parent(xp), CX_ELMNT) == 1)
- cprintf(cb, "[%s]", body);
- else
-#endif
cprintf(cb, "%s", body);
quote = 0;
break;
@@ -614,7 +604,12 @@ xml2json_encode_leafs(cxobj *xb,
/* special case YANG empty type */
if (body == NULL && strcmp(restype, "empty")==0){
quote = 0;
- cprintf(cb, "[null]");
+ if (keyword == Y_LEAF)
+ cprintf(cb, "[null]");
+ else if (keyword == Y_LEAF_LIST && strcmp(restype, "empty") == 0)
+ cprintf(cb, "[null]");
+ else
+ cprintf(cb, "null");
}
break;
default:
diff --git a/test/test_json_list.sh b/test/test_json_list.sh
index 1283ed42..c03a671d 100755
--- a/test/test_json_list.sh
+++ b/test/test_json_list.sh
@@ -13,19 +13,21 @@ module json{
prefix ex;
namespace "urn:example:clixon";
container c{
- leaf-list l1{
- type int32;
- }
- list l2{
- key name;
- leaf name{
- type int32;
- }
- leaf value{
- type string;
- }
- }
-
+ leaf-list l1{
+ type int32;
+ }
+ list l2{
+ key name;
+ leaf name{
+ type int32;
+ }
+ leaf value{
+ type string;
+ }
+ }
+ leaf extra{
+ type string;
+ }
}
}
EOF
@@ -58,6 +60,9 @@ testrun "two leaf-list" '{"json:c":{"l1":[1,2]}}' '123'
+testrun "multiple leaf-list" '{"json:c":{"l1":[1,2],"extra":"abc"}}' '12abc'
+
+
testrun "one list" '{"json:c":{"l2":[{"name":1,"value":"x"}]}}' '1x'
testrun "two list" '{"json:c":{"l2":[{"name":1,"value":"x"},{"name":2,"value":"y"}]}}' '1x2y'
diff --git a/test/test_json_null.sh b/test/test_json_null.sh
index f6675107..b402ecd1 100755
--- a/test/test_json_null.sh
+++ b/test/test_json_null.sh
@@ -71,7 +71,7 @@ expecteofx "$clixon_util_xml -ovJy $fyang" 0 "$JSON" "$XML"
# Leaf-lists single
XML=''
-JSON='{"json:leaf-lists":{"a":[null],"b":""}}'
+JSON='{"json:leaf-lists":{"a":[[null]],"b":[""]}}'
new "leaf-list single xml to json"
expecteofx "$clixon_util_xml -ovjy $fyang" 0 "$XML" "$JSON"
diff --git a/test/test_nacm_datanode_paths.sh b/test/test_nacm_datanode_paths.sh
index 776f660e..cb163e9c 100755
--- a/test/test_nacm_datanode_paths.sh
+++ b/test/test_nacm_datanode_paths.sh
@@ -126,7 +126,7 @@ new "Add NACM read path rule XML"
expectpart "$(curl -u andy:bar $CURLOPTS -X POST $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm -H 'Content-Type: application/yang-data+xml' -d 'limited-acllimitedtable*read/ex:tablepermit')" 0 "HTTP/$HVER 201"
new "Read NACM rule"
-expectpart "$(curl -u andy:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm/rule-list=limited-acl)" 0 "HTTP/$HVER 200" '{"ietf-netconf-acm:rule-list":\[{"name":"limited-acl","group":"limited","rule":\[{"name":"table","module-name":"\*","path":"/ex:table","access-operations":"read","action":"permit"}\]}\]}'
+expectpart "$(curl -u andy:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm/rule-list=limited-acl)" 0 "HTTP/$HVER 200" '{"ietf-netconf-acm:rule-list":\[{"name":"limited-acl","group":\["limited"\],"rule":\[{"name":"table","module-name":"\*","path":"/ex:table","access-operations":"read","action":"permit"}\]}\]}'
new "limit read OK"
expectpart "$(curl -u wilma:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/nacm-example:table/parameters/parameter=a)" 0 "HTTP/$HVER 200" '{"nacm-example:parameter":\[{"name":"a","value":"72"}\]}'
@@ -141,7 +141,7 @@ new "Add NACM read path rule JSON"
expectpart "$(curl -u andy:bar $CURLOPTS -X POST $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm -H 'Content-Type: application/yang-data+json' -d '{"ietf-netconf-acm:rule-list":[{"name":"limited-acl","group":"limited","rule":[{"name":"table","module-name":"*","path":"/ex:table","access-operations":"read","action":"permit"}]}]}')" 0 "HTTP/$HVER 201"
new "Read NACM rule"
-expectpart "$(curl -u andy:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm/rule-list=limited-acl)" 0 "HTTP/$HVER 200" '{"ietf-netconf-acm:rule-list":\[{"name":"limited-acl","group":"limited","rule":\[{"name":"table","module-name":"\*","path":"/ex:table","access-operations":"read","action":"permit"}\]}\]}'
+expectpart "$(curl -u andy:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm/rule-list=limited-acl)" 0 "HTTP/$HVER 200" '{"ietf-netconf-acm:rule-list":\[{"name":"limited-acl","group":\["limited"\],"rule":\[{"name":"table","module-name":"\*","path":"/ex:table","access-operations":"read","action":"permit"}\]}\]}'
new "limit read OK (Set rul w JSON)"
expectpart "$(curl -u wilma:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/nacm-example:table/parameters/parameter=a)" 0 "HTTP/$HVER 200" '{"nacm-example:parameter":\[{"name":"a","value":"72"}\]}'
diff --git a/test/test_restconf.sh b/test/test_restconf.sh
index 13baa5a9..e13d6222 100755
--- a/test/test_restconf.sh
+++ b/test/test_restconf.sh
@@ -386,7 +386,7 @@ function testrun()
fi
new "restconf get data type json"
- expectpart "$(curl $CURLOPTS -X GET $proto://$addr/restconf/data/clixon-example:state/op=42)" 0 '{"clixon-example:op":"42"}'
+ expectpart "$(curl $CURLOPTS -X GET $proto://$addr/restconf/data/clixon-example:state/op=42)" 0 '{"clixon-example:op":\["42"\]}'
new "restconf get state operation"
# Cant get shell macros to work, inline matching from lib.sh
@@ -398,7 +398,7 @@ function testrun()
fi
new "restconf get state operation type json"
- expectpart "$(curl $CURLOPTS -X GET $proto://$addr/restconf/data/clixon-example:state/op=42)" 0 '{"clixon-example:op":"42"}'
+ expectpart "$(curl $CURLOPTS -X GET $proto://$addr/restconf/data/clixon-example:state/op=42)" 0 '{"clixon-example:op":\["42"\]}'
new "restconf get state operation type xml"
# Cant get shell macros to work, inline matching from lib.sh