netconf-wg / restconf

9 stars 4 forks source link

JSON encoding of empty containers #54

Closed abierman closed 8 years ago

abierman commented 8 years ago

From Robert Wilton:

  1. The "D.1.1. Retrieve the Top-level API Resource" example looked slightly wrong to me. from the RESTCONF module definition in section 8 I would expect the data and operations container to be empty JSON objects.

OLD: The server might respond as follows:

  HTTP/1.1 200 OK
  Date: Mon, 23 Apr 2012 17:01:00 GMT
  Server: example-server
  Content-Type: application/yang.api+json

  {
    "ietf-restconf:restconf": {
      "data" : [ null ],
      "operations" : [ null ]
    }
  }

NEW: The server might respond as follows:

  HTTP/1.1 200 OK
  Date: Mon, 23 Apr 2012 17:01:00 GMT
  Server: example-server
  Content-Type: application/yang.api+json

  {
    "ietf-restconf:restconf": {
      "data" : { },
      "operations" : { }
    }
  }
abierman commented 8 years ago

We will ask Lada and check the YANG-JSON draft. That is the normative text for this issue

llhotka commented 8 years ago

I tend to agree with Rob. draft-ietf-netmod-yang-json defines [null] as the encoding of leafs with empty type, and nothing else. So using empty objects is IMO a better indication that some suppressed contents are inside.

mbj4668 commented 8 years ago

In fact, I think all occurences of [null] should be replaced with {}

abierman commented 8 years ago

This should not be changed because the JSON draft says an empty leaf is NULL

On Thu, Mar 10, 2016 at 3:27 AM, Martin Bjorklund notifications@github.com wrote:

Closed #54 https://github.com/netconf-wg/restconf/issues/54 via e9cfc09 https://github.com/netconf-wg/restconf/commit/e9cfc09af9a8fca054bce082557ac3eceb19ffb7 .

— Reply to this email directly or view it on GitHub https://github.com/netconf-wg/restconf/issues/54#event-584730064.

llhotka commented 8 years ago

IMO, the yang-json draft gives you no guideline, because the terms leaf and empty are meant in the narrow sense, i.e. a leaf node and and empty type, as defined in YANG. What you have here are some containers whose contents are omitted. So I think you can choose whatever makes most sense.