[CONTROLLER-785] JSON encoding for empty list inside container. Created: 08/Sep/14  Updated: 19/Oct/17  Resolved: 09/Sep/14

Status: Resolved
Project: controller
Component/s: restconf
Affects Version/s: Helium
Fix Version/s: None

Type: Bug
Reporter: Vratko Polak Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Linux
Platform: PC


Issue Links:
Duplicate
duplicates YANGTOOLS-288 JSON codec: do not emit empty lists Verified
External issue ID: 1744

 Description   

TLDR:

  • "bars": {"bar":[]}

    + "bars":{}

Long version:

In older ODL builds, JSON encoding for empty list inside a container did not have list name as kay at all. More recent builds, list name is there as a key, with [] as value. I believe the previous behavior was better, as it resulted in shorter JSON.

Standards and drafts are not very clear:
Example yang definition:
container bars {
list bar {
leaf foo

{ type string; }

}
}

We want to encode empty list in json.
According to http://tools.ietf.org/html/rfc6020#section-7.8.5 the XML representation would be:
<bars>
</bars>
(note zero occurrences of <bar>)

This draft for json lists http://tools.ietf.org/html/draft-lhotka-netmod-yang-json-02#section-3.2.4 only tells what to do with one or more elements.

But for containers http://tools.ietf.org/html/draft-lhotka-netmod-yang-json-02#section-3.2.2 I believe these two mappings are implied:

<bars>
<bar/>
</bars>
would perhaps map to {"bars":{"bar":[]}}

but
<bars>
</bars>
would definitely map to {"bars:{}}

Once again, the previous behavior seem to be the correct one.


Generated at Wed Feb 07 19:53:52 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.