Subject: [Netconf] Restconf: rendering the response to a GET on a list entry in json

From: "Alberto Gonzalez Prieto (albertgo)" <[email-masked]>
Date: Wed, 28 May 2014 23:39:09 +0000

Hi,

I would appreciate clarification on how to render the response to  a GET for a list entry.
More specifically, should  it be rendered as a list or differently (say like a container) ?

E.g.,

GET /restconf/data/example-jukebox:jukebox/
        library/artist/Foo%20Fighters

I understand that in XML, the response would be

<artist>

    <name> Foo Fighters </name>

    <album>

     (…)

    </album>

</artist>

How would that be rendered in json? Should it be rendered as list? I.e.,

{

    "artist" : [

     {

      "name" : "Foo Fighters",

      "album " : [

                      (…)

                  ]

             }

    ]

}

Or render it as containers are? I.e.,

{

    "artist" :  {

   "name" : "Foo Fighters",

   "album " : [

                      (…)

        ]

     }

}

Thanks,

Alberto

---

From: Andy Bierman <[email-masked]>
Date: Wed, 28 May 2014 17:55:29 -0700

On Wed, May 28, 2014 at 4:39 PM, Alberto Gonzalez Prieto (albertgo) <
[email-masked]> wrote:

>      (...)
>                       (...)

yes.

http://www.ietf.org/id/draft-ietf-netmod-yang-json-00.txt

see sec. 3.2.4

Andy

>                       (...)
> _______________________________________________
> Netconf mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netconf
>
>

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 29 May 2014 08:40:32 +0200

> http://www.ietf.org/id/draft-ietf-netmod-yang-json-00.txt

Well, that section defines the JSON encoding for a list but here the GET query asks for a single list entry, which clearly is an object.

I think it is up to the RESTCONF spec to define the contents of protocol messages, the cited draft deals with JSON encoding of repository contents. I can imagine that RESTCONF defines a special "response object" so that only the requested value is returned (without the name of the list), e.g.:

"data" :
  {
    "name": "Foo Fighters",
    "album": [ ...]
  }

Lada

-- 
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C

---

From: Andy Bierman <[email-masked]>
Date: Thu, 29 May 2014 00:14:55 -0700

On Wed, May 28, 2014 at 11:40 PM, Ladislav Lhotka <[email-masked]> wrote:

> >>  I would appreciate clarification on how to render the response to  a
> GET
> >> for a list entry.
> Well, that section defines the JSON encoding for a list but here the GET
> query asks for a single list entry, which clearly is an object.
>
> I think it is up to the RESTCONF spec to define the contents of protocol
> messages, the cited draft deals with JSON encoding of repository contents.
> I can imagine that RESTCONF defines a special "response object" so that
> only the requested value is returned (without the name of the list), e.g.:
>
> "data" :
>   {
>     "name": "Foo Fighters",
>     "album": [ ...]
>   }
>
>
No -- this has been discussed before.  A YANG list is encoded as an array
even if
there is only 1 of them. There is no need for special corner cases.

Andy

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 29 May 2014 09:24:47 +0200

On 29 May 2014, at 09:14, Andy Bierman <[email-masked]> wrote:

> No -- this has been discussed before.  A YANG list is encoded as an array even if

If the query was

GET /restconf/data/example-jukebox:jukebox/library/artist

(asking for the entire list), an array should be sent even if it contains only a single entry. But the original GET already asked for a specific entry, and this is IMO different.

Lada