Re: [netmod] RFC 7951 - JSON encoding of empty lists

2022-03-30 Thread Kent Watsen


> Also note that #1 isn't really of much use, as entire list and leaf-list 
> instances aren't even resources/endpoints in RESTCONF API - e.g. it's not 
> possible to GET the entire list.

True, but the “list-pagination” drafts (adoption-call in NETCONF) seek to 
change this. 

K. 



___
netmod mailing list
netmod@ietf.org
https://www.ietf.org/mailman/listinfo/netmod


Re: [netmod] RFC 7951 - JSON encoding of empty lists

2022-03-30 Thread Ladislav Lhotka
Hi,

Jack Rickard  writes:

> Hi,
>
> I think I've found an ambiguity in RFC 7951, and I'd like your input on what 
> was intended and what the best behaviour to exhibit is.
>
> Section 5.3 and 5.4 of RFC 7951 - JSON Encoding of Data Modeled with YANG 
> (ietf.org) 
> describe the encoding of leaf-lists and lists, however it's unclear how an 
> empty list should be encoded. Should it be encoded as:
>
>   1.  An empty array: {"list": []}
>   2.  A missing field: {}

Both variants are equivalent and should be supported by tools and libraries.

I can understand though that tools supporting both XML and JSON representations 
tend to prefer #2 because #1 doesn't exist in XML.

Also note that #1 isn't really of much use, as entire list and leaf-list 
instances aren't even resources/endpoints in RESTCONF API - e.g. it's not 
possible to GET the entire list.

Lada

>
> I've seen libraries go either way, libyang only accepts 2 but the python 
> yangson library accepts both (I'm not sure which is the default).
>
> Thanks,
> Jack Rickard
> he/him
> Software Engineer
> jack.rick...@microsoft.com
>
> [Microsoft Logo]
>
>
> ___
> netmod mailing list
> netmod@ietf.org
> https://www.ietf.org/mailman/listinfo/netmod

-- 
Ladislav Lhotka
Head, CZ.NIC Labs
PGP Key ID: 0xB8F92B08A9F76C67

___
netmod mailing list
netmod@ietf.org
https://www.ietf.org/mailman/listinfo/netmod


Re: [netmod] RFC 7951 - JSON encoding of empty lists

2022-03-29 Thread Kent Watsen
Hi Jack,

Yes, indeed, I did misunderstand your original #2.

Between an empty list node appearing (as just "[ ]") versus not appearing at 
all, I do not think that the JSON encoding is defined, and so tooling should 
accept either encoding, IMO.   [FWIW, XML has only one encoding].

Personally, I initially preferred #1 (because it is more self-describing), but 
implementation-details drove me to #2.

Kent // contributor


> On Mar 29, 2022, at 2:19 PM, Jack Rickard  wrote:
> 
> Hi Kent,
> 
> Thanks very much for the response. However, I'm slightly worried you've 
> misunderstood my examples, and as I've been fighting in the #1 corner I want 
> to make sure I give #2 a fair chance.
> 
> Given this schema:
> module test {
>   prefix "test";
>   namespace "urn:test";
> 
>   container test {
> leaf foo {type string;}
> leaf-list bar {type string;}
> leaf baz {type string;}
>   }
> }
> 
> Is this valid (#1):
> {
> "test:test": {
> "foo": "test1",
> "bar": [],
> "baz": "test2"
> }
> }
> 
> and is this valid (#2):
> {
> "test:test": {
> "foo": "test1",
> "baz": "test2"
> }
> }
> 
> To make sure I didn't miss something I verified this with yanglint 0.16.105 
> (what ubuntu gave me), and that accepts #2 but not #1 (it rejects #1 with err 
> : Invalid JSON data (unexpected value). (/test:test/bar)).
> To be really clear this is accepted:
> {
> "test:test": {
>     "foo": "test1",
> "bar": ["test3"],
> "baz": "test2"
> }
> }
> 
> Thanks,
> Jack
> 
> From: Kent Watsen 
> Sent: 29 March 2022 18:14
> To: Jack Rickard 
> Cc: draft-ietf-netmod-yang-j...@ietf.org 
> ; netmod@ietf.org 
> Subject: Re: [netmod] RFC 7951 - JSON encoding of empty lists
>  
> #1 is an empty list (or leaf-list).  This is what you want.
> 
> #2 is a list containing one element, which is an empty container (or, in 
> Python term's, an empty 'dict').
> 
> Yanglint 1.x used to accept #1, kinks are being worked out on the 2.x branch.
> 
> Kent // contributor
> 
> 
>> On Mar 29, 2022, at 10:21 AM, Jack Rickard 
>> > <mailto:jack.rickard=40microsoft@dmarc.ietf.org>> wrote:
>> 
>> Hi,
>>  
>> I think I’ve found an ambiguity in RFC 7951, and I’d like your input on what 
>> was intended and what the best behaviour to exhibit is.
>>  
>> Section 5.3 and 5.4 of RFC 7951 - JSON Encoding of Data Modeled with YANG 
>> (ietf.org) 
>> <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdatatracker.ietf.org%2Fdoc%2Fhtml%2Frfc7951%23section-5.3=04%7C01%7Cjack.rickard%40microsoft.com%7Ca33f2d22f70f4de7a87808da11a79ae4%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637841709447361395%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000=2jqJW1VVJyft9CVC3T5xCgXvlt4Zsd7c7mdtBrKSpdM%3D=0>
>>  describe the encoding of leaf-lists and lists, however it’s unclear how an 
>> empty list should be encoded. Should it be encoded as:
>> An empty array: {“list”: []}
>> A missing field: {}
>>  
>> I’ve seen libraries go either way, libyang only accepts 2 but the python 
>> yangson library accepts both (I’m not sure which is the default).
>>  
>> Thanks,
>> Jack Rickard 
>> he/him 
>> Software Engineer 
>> jack.rick...@microsoft.com <mailto:jack.rick...@microsoft.com> 
>> 
>> 
>>  
>>  
>> ___
>> netmod mailing list
>> netmod@ietf.org <mailto:netmod@ietf.org>
>> https://www.ietf.org/mailman/listinfo/netmod 
>> <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ietf.org%2Fmailman%2Flistinfo%2Fnetmod=04%7C01%7Cjack.rickard%40microsoft.com%7Ca33f2d22f70f4de7a87808da11a79ae4%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637841709447361395%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000=RJxmETMYeLjdtqejd%2BsfV6jkjjAuQAxZ%2FeQkf14lZT0%3D=0>
___
netmod mailing list
netmod@ietf.org
https://www.ietf.org/mailman/listinfo/netmod


Re: [netmod] RFC 7951 - JSON encoding of empty lists

2022-03-29 Thread Jack Rickard
Hi Kent,

Thanks very much for the response. However, I'm slightly worried you've 
misunderstood my examples, and as I've been fighting in the #1 corner I want to 
make sure I give #2 a fair chance.

Given this schema:
module test {
  prefix "test";
  namespace "urn:test";

  container test {
leaf foo {type string;}
leaf-list bar {type string;}
leaf baz {type string;}
  }
}

Is this valid (#1):
{
"test:test": {
"foo": "test1",
"bar": [],
"baz": "test2"
}
}

and is this valid (#2):
{
"test:test": {
"foo": "test1",
"baz": "test2"
}
}

To make sure I didn't miss something I verified this with yanglint 0.16.105 
(what ubuntu gave me), and that accepts #2 but not #1 (it rejects #1 with err : 
Invalid JSON data (unexpected value). (/test:test/bar)).
To be really clear this is accepted:
{
"test:test": {
"foo": "test1",
"bar": ["test3"],
"baz": "test2"
    }
}

Thanks,
Jack

________
From: Kent Watsen 
Sent: 29 March 2022 18:14
To: Jack Rickard 
Cc: draft-ietf-netmod-yang-j...@ietf.org 
; netmod@ietf.org 
Subject: Re: [netmod] RFC 7951 - JSON encoding of empty lists

#1 is an empty list (or leaf-list).  This is what you want.

#2 is a list containing one element, which is an empty container (or, in Python 
term's, an empty 'dict').

Yanglint 1.x used to accept #1, kinks are being worked out on the 2.x branch.

Kent // contributor


On Mar 29, 2022, at 10:21 AM, Jack Rickard 
mailto:jack.rickard=40microsoft@dmarc.ietf.org>>
 wrote:

Hi,

I think I’ve found an ambiguity in RFC 7951, and I’d like your input on what 
was intended and what the best behaviour to exhibit is.

Section 5.3 and 5.4 of RFC 7951 - JSON Encoding of Data Modeled with YANG 
(ietf.org)<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdatatracker.ietf.org%2Fdoc%2Fhtml%2Frfc7951%23section-5.3=04%7C01%7Cjack.rickard%40microsoft.com%7Ca33f2d22f70f4de7a87808da11a79ae4%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637841709447361395%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000=2jqJW1VVJyft9CVC3T5xCgXvlt4Zsd7c7mdtBrKSpdM%3D=0>
 describe the encoding of leaf-lists and lists, however it’s unclear how an 
empty list should be encoded. Should it be encoded as:

  1.  An empty array: {“list”: []}
  2.  A missing field: {}


I’ve seen libraries go either way, libyang only accepts 2 but the python 
yangson library accepts both (I’m not sure which is the default).

Thanks,
Jack Rickard
he/him
Software Engineer
jack.rick...@microsoft.com<mailto:jack.rick...@microsoft.com>




___
netmod mailing list
netmod@ietf.org<mailto:netmod@ietf.org>
https://www.ietf.org/mailman/listinfo/netmod<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ietf.org%2Fmailman%2Flistinfo%2Fnetmod=04%7C01%7Cjack.rickard%40microsoft.com%7Ca33f2d22f70f4de7a87808da11a79ae4%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637841709447361395%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000=RJxmETMYeLjdtqejd%2BsfV6jkjjAuQAxZ%2FeQkf14lZT0%3D=0>

___
netmod mailing list
netmod@ietf.org
https://www.ietf.org/mailman/listinfo/netmod


Re: [netmod] RFC 7951 - JSON encoding of empty lists

2022-03-29 Thread Kent Watsen
#1 is an empty list (or leaf-list).  This is what you want.

#2 is a list containing one element, which is an empty container (or, in Python 
term's, an empty 'dict').

Yanglint 1.x used to accept #1, kinks are being worked out on the 2.x branch.

Kent // contributor


> On Mar 29, 2022, at 10:21 AM, Jack Rickard 
>  wrote:
> 
> Hi,
>  
> I think I’ve found an ambiguity in RFC 7951, and I’d like your input on what 
> was intended and what the best behaviour to exhibit is.
>  
> Section 5.3 and 5.4 of RFC 7951 - JSON Encoding of Data Modeled with YANG 
> (ietf.org)  
> describe the encoding of leaf-lists and lists, however it’s unclear how an 
> empty list should be encoded. Should it be encoded as:
> An empty array: {“list”: []}
> A missing field: {}
>  
> I’ve seen libraries go either way, libyang only accepts 2 but the python 
> yangson library accepts both (I’m not sure which is the default).
>  
> Thanks,
> Jack Rickard 
> he/him 
> Software Engineer 
> jack.rick...@microsoft.com  
> 
> 
>  
>  
> ___
> netmod mailing list
> netmod@ietf.org 
> https://www.ietf.org/mailman/listinfo/netmod 
> 
___
netmod mailing list
netmod@ietf.org
https://www.ietf.org/mailman/listinfo/netmod


[netmod] RFC 7951 - JSON encoding of empty lists

2022-03-29 Thread Jack Rickard
Hi,

I think I've found an ambiguity in RFC 7951, and I'd like your input on what 
was intended and what the best behaviour to exhibit is.

Section 5.3 and 5.4 of RFC 7951 - JSON Encoding of Data Modeled with YANG 
(ietf.org) describe 
the encoding of leaf-lists and lists, however it's unclear how an empty list 
should be encoded. Should it be encoded as:

  1.  An empty array: {"list": []}
  2.  A missing field: {}

I've seen libraries go either way, libyang only accepts 2 but the python 
yangson library accepts both (I'm not sure which is the default).

Thanks,
Jack Rickard
he/him
Software Engineer
jack.rick...@microsoft.com

[Microsoft Logo]


___
netmod mailing list
netmod@ietf.org
https://www.ietf.org/mailman/listinfo/netmod