Details
-
Bug
-
Status: Resolved
-
Resolution: Duplicate
-
Helium
-
None
-
None
-
Operating System: Linux
Platform: PC
-
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
}
}
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.
Attachments
Issue Links
- duplicates
-
YANGTOOLS-288 JSON codec: do not emit empty lists
- Verified