* [JSON leaf-list output single element leaf-list does not use array](https://github.com/clicon/clixon/issues/289)

This commit is contained in:
Olof hagsand 2021-11-29 13:43:10 +01:00
parent 339b744835
commit f4b35cb270
5 changed files with 30 additions and 30 deletions

View file

@ -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]}}' '<c xmlns="urn:example:clixon"
testrun "three leaf-list" '{"json:c":{"l1":[1,2,3]}}' '<c xmlns="urn:example:clixon"><l1>1</l1><l1>2</l1><l1>3</l1></c>'
testrun "multiple leaf-list" '{"json:c":{"l1":[1,2],"extra":"abc"}}' '<c xmlns="urn:example:clixon"><l1>1</l1><l1>2</l1><extra>abc</extra></c>'
testrun "one list" '{"json:c":{"l2":[{"name":1,"value":"x"}]}}' '<c xmlns="urn:example:clixon"><l2><name>1</name><value>x</value></l2></c>'
testrun "two list" '{"json:c":{"l2":[{"name":1,"value":"x"},{"name":2,"value":"y"}]}}' '<c xmlns="urn:example:clixon"><l2><name>1</name><value>x</value></l2><l2><name>2</name><value>y</value></l2></c>'