Re: [netmod] RFC 7951 - JSON encoding of empty lists
Kent Watsen <kent+ietf@watsen.net> Tue, 29 March 2022 20:30 UTC
Return-Path: <0100017fd75f4c6a-a7d746e2-abea-4dac-be3a-2ef8f2d63230-000000@amazonses.watsen.net>
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 B70213A1BFD for <netmod@ietfa.amsl.com>; Tue, 29 Mar 2022 13:30:28 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.806
X-Spam-Level:
X-Spam-Status: No, score=-1.806 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, HTTPS_HTTP_MISMATCH=0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=amazonses.com
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 dtXxAGFaKqU9 for <netmod@ietfa.amsl.com>; Tue, 29 Mar 2022 13:30:24 -0700 (PDT)
Received: from a48-92.smtp-out.amazonses.com (a48-92.smtp-out.amazonses.com [54.240.48.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id B8B383A1C00 for <netmod@ietf.org>; Tue, 29 Mar 2022 13:30:23 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw; d=amazonses.com; t=1648585822; h=From:Message-Id:Content-Type:Mime-Version:Subject:Date:In-Reply-To:Cc:To:References:Feedback-ID; bh=Q0FSbwBw/lkX8+p3DOv8Bc9I5yprW5RAFEUE4U5TrF4=; b=AEPIM7BMP/cgZSi0Bak/3Nd9v9nkV5V+6Fms/P1PaHa0K/jaxsBpGNfSQMY0SJcc +xlUsSJrKegh6yTaOGwbnyyk9QqurVq1thK1tpz+wq/rnUOWS1cuEPdL7Q1fnDRFzUU yc+qhfbD6U/OWUE3Pk3OsRAOyDBvprPyvos2kSdI=
From: Kent Watsen <kent+ietf@watsen.net>
Message-ID: <0100017fd75f4c6a-a7d746e2-abea-4dac-be3a-2ef8f2d63230-000000@email.amazonses.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_D7E5A8A5-D69C-4636-9411-1DDB82CBE884"
Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.60.0.1.1\))
Date: Tue, 29 Mar 2022 20:30:21 +0000
In-Reply-To: <HE1PR83MB0378DFCEB5C60C880A56EE38881E9@HE1PR83MB0378.EURPRD83.prod.outlook.com>
Cc: "netmod@ietf.org" <netmod@ietf.org>, "mvasko@cesnet.cz" <mvasko@cesnet.cz>
To: Jack Rickard <jack.rickard@microsoft.com>
References: <HE1PR83MB03785D65431C5DF40FA08FEA881E9@HE1PR83MB0378.EURPRD83.prod.outlook.com> <0100017fd6abba70-36f5982f-085f-4c24-b0cd-35e90700b495-000000@email.amazonses.com> <HE1PR83MB0378DFCEB5C60C880A56EE38881E9@HE1PR83MB0378.EURPRD83.prod.outlook.com>
X-Mailer: Apple Mail (2.3693.60.0.1.1)
Feedback-ID: 1.us-east-1.DKmIRZFhhsBhtmFMNikgwZUWVrODEw9qVcPhqJEI2DA=:AmazonSES
X-SES-Outgoing: 2022.03.29-54.240.48.92
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/xvfZr4YliDKsIyQcZg6JZiudBmQ>
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: Tue, 29 Mar 2022 20:30:29 -0000
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 <jack.rickard@microsoft.com> 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 <kent+ietf@watsen.net> > Sent: 29 March 2022 18:14 > To: Jack Rickard <jack.rickard@microsoft.com> > Cc: draft-ietf-netmod-yang-json@ietf.org <draft-ietf-netmod-yang-json@ietf.org>; netmod@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 <jack.rickard=40microsoft.com@dmarc.ietf.org <mailto:jack.rickard=40microsoft.com@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&data=04%7C01%7Cjack.rickard%40microsoft.com%7Ca33f2d22f70f4de7a87808da11a79ae4%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637841709447361395%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=2jqJW1VVJyft9CVC3T5xCgXvlt4Zsd7c7mdtBrKSpdM%3D&reserved=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.rickard@microsoft.com <mailto:jack.rickard@microsoft.com> >> >> <image001.png> >> >> >> _______________________________________________ >> 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&data=04%7C01%7Cjack.rickard%40microsoft.com%7Ca33f2d22f70f4de7a87808da11a79ae4%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637841709447361395%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=RJxmETMYeLjdtqejd%2BsfV6jkjjAuQAxZ%2FeQkf14lZT0%3D&reserved=0>
- [netmod] RFC 7951 - JSON encoding of empty lists Jack Rickard
- Re: [netmod] RFC 7951 - JSON encoding of empty li… Kent Watsen
- Re: [netmod] RFC 7951 - JSON encoding of empty li… Jack Rickard
- Re: [netmod] RFC 7951 - JSON encoding of empty li… Kent Watsen
- Re: [netmod] RFC 7951 - JSON encoding of empty li… Ladislav Lhotka
- Re: [netmod] RFC 7951 - JSON encoding of empty li… Kent Watsen