Display options (JSON and XML) showing different behaviors

My yang file contains multiple containers or list. The leaves/list inside the containers will have both config item as well as non config(config false) item.

When I enter “show container-name” it lists only the non-config item as expected.

But “show container-name | display json” or “show container-name | display xml” displays all the items inside the container, including the config(config false) leaves or list as well.

This problem is specific to “json and xml” and not seen in other display options like curly-braces, keypath or xpath.

Any idea how to avoid the config items being displayed from XML and JSON?

Thanks

Either you are using a very old version of ConfD (if so, try using the latest version) or you need to provide an example that shows the behavior you describe.

Below is a sample from yang file

list interface
{
    description "The list of configured interfaces on the device";
    key "interface-id";

    leaf interface-id
    {
        description "Interface identifier";
        type yang:counter32;
	}
	leaf mtu
	{
		description "MTU size for this interface";
		type yang:counter32;
		default 1500;
	}
    leaf state-enable
    {
        description "Enable or disable";
        type boolean;
        default false;
    }
    leaf num-of-pkts-received
    {
        config false;
        tailf:callpoint interface-stats;
        description "Number of packets received in this interface";
        type yang:counter64;
    }
    leaf num-of-pkts-sent
    {
        config false;
        tailf:callpoint interface-stats;
        description "Number of packets sent from this interface";
        type yang:counter64;
    }
}

It contains config elements like mtu,state-enable and non-config(stats) like num-of-pkts-received and num-of-pkts-sent.

If I want to check the interface stats. The below command gives the expected output.

localhost# show interface 
INTERFACE      NUM OF PKTS	NUM OF PKTS
ID    		   RECEIVED		SENT
--------------------------------------------
0			   2351330		5271474
1			   3333907964	1228799628
2			   1866302		2293135483

But If I add the display option as json. It shows the entire containter. It does not differentiate the non-config(stats) and config elements.

localhost# show interface | display json
  "data": {
    "interface": [
      {
        "interface-id": 0,
        "mtu": 1000,
		"state-enable" : true,
		"num-of-pkts-received" :2351330,
		"num-of-pkts-sent":5271474
	  },
	  {
        "interface-id": 1,
		"state-enable" : true,
		"num-of-pkts-received" :3333907964,
		"num-of-pkts-sent":1228799628
	  },
	  {
        "interface-id": 2,
        "mtu": 1400,
		"state-enable" : true,
		"num-of-pkts-received" :1866302,
		"num-of-pkts-sent":2293135483
	  },
	  ]
	}

The problem is seen with only JSON and XML and not seen in other display options like curly-braces, keypath or xpath.

localhost# show interface  | display xpath
/interface[interface-id='0']/num-of-pkts-received 2351330
/interface[interface-id='0']/num-of-pkts-sent 5271474
/interface[interface-id='1']/num-of-pkts-received 3333907964
/interface[interface-id='1']/num-of-pkts-sent 1228799628
/interface[interface-id='2']/num-of-pkts-received 1866302
/interface[interface-id='2']/num-of-pkts-sent 2293135483

That issue was corrected in ConfD 7.2.2 for XML and 7.4.1 for JSON output. Latest version is 7.5.2
If you are using for example ConfD 7.2.1 or earlier you can use MAAPI to get the operational data only. Example using the confd_load tool:

$ confd_load -Fo -O -p /interface
$ confd_load -Fp -O -p /interface

Thanks for the info.