libyang icon indicating copy to clipboard operation
libyang copied to clipboard

libyang does not behave as expected for empty leaf-list.

Open ngniksnikhil opened this issue 2 years ago • 1 comments

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.

ngniksnikhil avatar Jun 15 '23 06:06 ngniksnikhil

Empty JSON data (just {}) and your input.json represent the exact same data (none) so libyang does not distinguish between them. Why should it?

michalvasko avatar Jun 15 '23 07:06 michalvasko