Uploaded image for project: 'controller'
  1. controller
  2. CONTROLLER-785

JSON encoding for empty list inside container.

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Duplicate
    • Helium
    • None
    • restconf
    • 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

      { 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.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              Unassigned Unassigned
              vrpolak Vratko Polak
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: