Re: [netmod] json empty leaf encoding strangeness [Re: WG Last Call for draft-ietf-netmod-yang-json-04 (until 2015-06-29)]

Ladislav Lhotka <ladislav.lhotka@nic.cz> Sat, 18 December 2021 18:04 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 39D343A1086 for <netmod@ietfa.amsl.com>; Sat, 18 Dec 2021 10:04:54 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.899
X-Spam-Level:
X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham 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 HzSIAAD7hkTS for <netmod@ietfa.amsl.com>; Sat, 18 Dec 2021 10:04:49 -0800 (PST)
Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (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 7E7CD3A1084 for <netmod@ietf.org>; Sat, 18 Dec 2021 10:04:48 -0800 (PST)
Received: from localhost (unknown [IPv6:2a01:5e0:29:ffff::82e]) by mail.nic.cz (Postfix) with ESMTPSA id 8945A1409FE; Sat, 18 Dec 2021 19:04:45 +0100 (CET)
From: Ladislav Lhotka <ladislav.lhotka@nic.cz>
To: Christian Hopps <chopps@chopps.org>, Carsten Bormann <cabo@tzi.org>
Cc: Christian Hopps <chopps@chopps.org>, Eliot Lear <lear@lear.ch>, "netmod@ietf.org" <netmod@ietf.org>
In-Reply-To: <DE0EA6BB-A3FB-40C9-BBDB-8ED8200E7FEE@chopps.org>
References: <D1A4CEB7.B22F7%kwatsen@juniper.net> <20150624145325.GB38016@elstar.local> <m2lhf27sko.fsf@birdie.labs.nic.cz> <1640D503-A676-4BC5-82E6-E08ED04F7106@chopps.org> <4d8189be-aeea-9ed9-b43f-80580acd2b9a@lear.ch> <1FE71A45-2B1A-4B46-96FF-A1D781F4C47D@tzi.org> <DE0EA6BB-A3FB-40C9-BBDB-8ED8200E7FEE@chopps.org>
Mail-Followup-To: Christian Hopps <chopps@chopps.org>, Carsten Bormann <cabo@tzi.org>, Christian Hopps <chopps@chopps.org>, Eliot Lear <lear@lear.ch>, "netmod@ietf.org" <netmod@ietf.org>
Date: Sat, 18 Dec 2021 19:04:45 +0100
Message-ID: <875yrlhjr6.fsf@nic.cz>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Virus-Scanned: clamav-milter 0.102.4 at mail
X-Virus-Status: Clean
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/I2cK1chDa-BPvehWduJTC2UPHdY>
Subject: Re: [netmod] json empty leaf encoding strangeness [Re: WG Last Call for draft-ietf-netmod-yang-json-04 (until 2015-06-29)]
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: Sat, 18 Dec 2021 18:04:54 -0000

Christian Hopps <chopps@chopps.org> writes:

>> On Dec 18, 2021, at 7:59 AM, Carsten Bormann <cabo@tzi.org> wrote:
>> 
>> On 2021-12-18, at 09:20, Eliot Lear <lear@lear.ch> wrote:
>>> 
>>> Still it seems like the right thing to do, in order to fall into line with the target language spec.
>> 
>> But that’s not what YANG was designed for.
>> YANG is a data modeling language, which incidentally has a couple of representation formats (YANG-XML, YANG-JSON, YANG-CBOR).
>> There is no intention for the YANG generic data model (the set of all data models YANG can express) to cover the generic data model of the representation format.
>
> To be clear, the question I raised is about an encoding of YANG modeled data. In particular the JSON encoding of the YANG empty leaf element.
>
>   https://datatracker.ietf.org/doc/html/rfc7951#section-6.9
>
> the justification for having the very odd encoding was that there was some belief that some programming languages might have trouble with the obvious JSON "null" encoding (which stands for "no value" in JSON -- exactly what we want here). An old email gave a python example to try and illustrate this, except the python example was an incorrect use of python for this case (presence check) and not a problem with the natural JSON encoding for no value items. In fact correctly written python code has no problem at all with the more natural "null" encoding, and results in the correct internal representation in python to boot.
>
> This isn't about the YANG specification in general, or making YANG
> conform to any particular language. It's just about the a choice in
> the specification for the encoding of YANG in a particular format
> (JSON).

The original proposal (even before my individual draft appeared in the NETMOD WG) was actually just "null". We'd been discussing it back in March 2012 in a smaller group (Andy, Jürgen, Martin, Phil Shafer and myself), and Phil objected to this encoding of empty values. His arguments were, for example:

    'foo: null'?  Doesn't that make testing for empty values a major
    pain?  'if (foo)' would not work.

    JSON evolved from Javascript, so it must keep the javascript
    meanings for these keywords.

It is indeed true that tests in JavaScript cannot really distinguish between a non-existent member and member with the value of 'null'. I remember I wasn't happy about this change but I thought it wasn't a big deal.

Lada

>
> Thanks,
> Chris.
>
>
>
>> 
>> While RFC 8791 (and before it RFC 8040) extended YANG to be able to describe data in flight, there is no intention that YANG can be used to describe the entire expressibility of the representation format.  We have Relax-NG, CDDL, and a few other modeling approaches if we need that.
>
>> Grüße, Carsten
>> 
>

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