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> Sun, 19 December 2021 08:25 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 5EF843A0AEF for <netmod@ietfa.amsl.com>; Sun, 19 Dec 2021 00:25:26 -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 fM-7CrzVSBip for <netmod@ietfa.amsl.com>; Sun, 19 Dec 2021 00:25:21 -0800 (PST)
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 958813A0AEB for <netmod@ietf.org>; Sun, 19 Dec 2021 00:25:20 -0800 (PST)
Received: from localhost (unknown [IPv6:2a01:5e0:29:ffff::82e]) by mail.nic.cz (Postfix) with ESMTPSA id 2FEE8140A24; Sun, 19 Dec 2021 09:25:14 +0100 (CET)
From: Ladislav Lhotka <ladislav.lhotka@nic.cz>
To: 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: <80C39075-B512-4771-BD06-077423A361EC@tzi.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> <875yrlhjr6.fsf@nic.cz> <80C39075-B512-4771-BD06-077423A361EC@tzi.org>
Mail-Followup-To: Carsten Bormann <cabo@tzi.org>, Christian Hopps <chopps@chopps.org>, Eliot Lear <lear@lear.ch>, "netmod@ietf.org" <netmod@ietf.org>
Date: Sun, 19 Dec 2021 09:25:13 +0100
Message-ID: <8735mpgfx2.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/clUs8D3jsTAFxk7IqkCIYHi1Eu8>
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: Sun, 19 Dec 2021 08:25:27 -0000

Carsten Bormann <cabo@tzi.org> writes:

> On 18. Dec 2021, at 19:04, Ladislav Lhotka <ladislav.lhotka@nic.cz> wrote:
>> 
>>    'foo: null'?  Doesn't that make testing for empty values a major
>>    pain?  'if (foo)' would not work.
>
> Same with »false«, which 7951 is not escaping into an array.  This
> argument simply doesn’t hold water.  As was mentioned, you would
> check »”foo” in o«, which works for null, false, and all other
> values that may happen to be falsy(*) in the platform.

The whole story is that Phil wanted to have both empty and boolean values as JSON strings. The result was a compromise, and I thought that [null] was a much better choice because, unlike "null" string, it cannot otherwise appear as a valid value of a YANG leaf.

>
>>    JSON evolved from Javascript, so it must keep the javascript
>>    meanings for these keywords.
>
> That is a common misconception that must be stamped out, but we have
> json@ietf.org for that discussion.

It's not that I am defending these views. I did argue with RFC 4627, but not too hard, as this seemed like a marginal issue at that time - much more fundamental objections against the JSON representation were raised back then.

>
>> 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.
>
> As mentioned, they can.
> And, yes, this little unnecessary complexity is not a big deal even if it is based on mistaken beliefs; every non-trivial protocol has some unburied zombies in the basement.

Right, in hindsight it was a mistake. It is also worth noting that [null] is only an on-the-wire value, so e.g. None can be used internally in Python. I have written a lot of related running code and don't find it a serious problem.  

Lada

>
> Grüße, Carsten
>
> (*) falsy: converted to false when implicitly coerced to a Boolean (Ant.: truthy)
>

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