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

Ladislav Lhotka <ladislav.lhotka@nic.cz> Wed, 30 March 2022 07:53 UTC

Return-Path: <ladislav.lhotka@nic.cz>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 227473A0FE3 for <netmod@ietfa.amsl.com>; Wed, 30 Mar 2022 00:53:35 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.909
X-Spam-Level:
X-Spam-Status: No, score=-1.909 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001] autolearn=unavailable autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2iQurCb-sunf for <netmod@ietfa.amsl.com>; Wed, 30 Mar 2022 00:53:31 -0700 (PDT)
Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 0379C3A0FF5 for <netmod@ietf.org>; Wed, 30 Mar 2022 00:53:30 -0700 (PDT)
Received: from wedge.nic.cz (unknown [IPv6:2001:718:1a02:1::a00]) by mail.nic.cz (Postfix) with ESMTPSA id DC69D13FAA4; Wed, 30 Mar 2022 09:53:26 +0200 (CEST)
From: Ladislav Lhotka <ladislav.lhotka@nic.cz>
To: Jack Rickard <jack.rickard=40microsoft.com@dmarc.ietf.org>, "draft-ietf-netmod-yang-json@ietf.org" <draft-ietf-netmod-yang-json@ietf.org>, "netmod@ietf.org" <netmod@ietf.org>
In-Reply-To: <HE1PR83MB03785D65431C5DF40FA08FEA881E9@HE1PR83MB0378.EURPRD83.prod.outlook.com>
References: <HE1PR83MB03785D65431C5DF40FA08FEA881E9@HE1PR83MB0378.EURPRD83.prod.outlook.com>
Mail-Followup-To: Jack Rickard <jack.rickard=40microsoft.com@dmarc.ietf.org>, "draft-ietf-netmod-yang-json@ietf.org" <draft-ietf-netmod-yang-json@ietf.org>, "netmod@ietf.org" <netmod@ietf.org>
Date: Wed, 30 Mar 2022 09:53:26 +0200
Message-ID: <87sfqzlvux.fsf@nic.cz>
MIME-Version: 1.0
Content-Type: text/plain
X-Virus-Scanned: clamav-milter 0.103.4 at mail
X-Virus-Status: Clean
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/Jlgpucc0wI6YpCIuXk6k1gicjsE>
Subject: Re: [netmod] RFC 7951 - JSON encoding of empty lists
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 30 Mar 2022 07:53:35 -0000

Hi,

Jack Rickard <jack.rickard=40microsoft.com@dmarc.ietf.org> 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)<https://datatracker.ietf.org/doc/html/rfc7951#section-5.3> 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.rickard@microsoft.com<mailto:jack.rickard@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