libyang
libyang copied to clipboard
libyang does not behave as expected for empty leaf-list.
test-yang.yang:
module test-yang {
namespace "urn:company:params:xml:ns:yang:test-yang";
prefix test-yang;
container a {
leaf-list b {
type string;
}
leaf-list c {
type uint16;
}
}
}
input.json:
{
"test-yang:a":
{
"b": [],
"c": []
}
}
I ran yanglint from libyang version 2.1.80 for above test-yang.yang and input.json
$./bin/yanglint -f json /tmp/test-yang.yang /tmp/input.json
{
}
I got empty { } as output. Isn't this incorrect? From output it seems this has been deleted but ideally it should be same as input.json.
Empty JSON data (just {}) and your input.json represent the exact same data (none) so libyang does not distinguish between them. Why should it?