Re: [netmod] attributes in draft-lhotka-netmod-yang-json
Ladislav Lhotka <lhotka@nic.cz> Wed, 26 March 2014 15:05 UTC
Return-Path: <lhotka@nic.cz>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id CC81E1A02D8 for <netmod@ietfa.amsl.com>; Wed, 26 Mar 2014 08:05:22 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.661
X-Spam-Level:
X-Spam-Status: No, score=-0.661 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HELO_EQ_CZ=0.445, HOST_EQ_CZ=0.904, T_RP_MATCHES_RCVD=-0.01] autolearn=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 3Ki0MeKdWDaj for <netmod@ietfa.amsl.com>; Wed, 26 Mar 2014 08:05:21 -0700 (PDT)
Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) by ietfa.amsl.com (Postfix) with ESMTP id F26851A0147 for <netmod@ietf.org>; Wed, 26 Mar 2014 08:05:20 -0700 (PDT)
Received: from ladislavs-air-2.lan (ip-94-113-93-24.net.upcbroadband.cz [94.113.93.24]) by mail.nic.cz (Postfix) with ESMTPSA id 808C313F686; Wed, 26 Mar 2014 16:05:18 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=nic.cz; s=default; t=1395846318; bh=z3bl2UvZNPzW6KEXo9w5n5dk5I+qzX6+hSqpChA6L6U=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Content-Transfer-Encoding:Message-Id:References:To; b=DucylAv0nQmk2RYpM3psIlVhJu0R8PsssXQNYyBpv9b9xj0kPt8S/CUJh+Vn/iAZD zPvu7QKilBUHjlr+RZ4mD7/FqTD2sQueoiFa22oQWHm0opCUOwZ5iavPY+oBRwEudr ySEKFVsKOg3uZWYn9hOzvz9nd9jXDF/pIKgORNyk=
Content-Type: text/plain; charset="windows-1252"
Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\))
From: Ladislav Lhotka <lhotka@nic.cz>
In-Reply-To: <CABCOCHSmt-Mr2fe-Xmpajz0v8jg=XOJsY4CMEtCBe1GzTbL6EA@mail.gmail.com>
Date: Wed, 26 Mar 2014 16:05:11 +0100
Content-Transfer-Encoding: quoted-printable
Message-Id: <6F6EF691-5134-4243-B25D-96C54760741C@nic.cz>
References: <20140326.145737.580242632261637255.mbj@tail-f.com> <A169C9A0-970B-4F7B-B102-61543EE553BD@nic.cz> <CABCOCHTg5T+k_LzyNz=bwUKC5AS5gYcBVODL4ZUihUWXQbDbkQ@mail.gmail.com> <20140326.152737.330538996469661145.mbj@tail-f.com> <CABCOCHSmt-Mr2fe-Xmpajz0v8jg=XOJsY4CMEtCBe1GzTbL6EA@mail.gmail.com>
To: Andy Bierman <andy@yumaworks.com>
X-Mailer: Apple Mail (2.1874)
X-Virus-Scanned: clamav-milter 0.97.8 at mail
X-Virus-Status: Clean
Archived-At: http://mailarchive.ietf.org/arch/msg/netmod/yJwpRlEYy4BH1CsV7f_tTp05mLs
Cc: "netmod@ietf.org" <netmod@ietf.org>
Subject: Re: [netmod] attributes in draft-lhotka-netmod-yang-json
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.15
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: <http://www.ietf.org/mail-archive/web/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, 26 Mar 2014 15:05:23 -0000
On 26 Mar 2014, at 15:43, Andy Bierman <andy@yumaworks.com> wrote: > > > > On Wed, Mar 26, 2014 at 7:27 AM, Martin Bjorklund <mbj@tail-f.com> wrote: > Andy Bierman <andy@yumaworks.com> wrote: > > On Wed, Mar 26, 2014 at 7:10 AM, Ladislav Lhotka <lhotka@nic.cz> wrote: > > > > > > > > On 26 Mar 2014, at 14:57, Martin Bjorklund <mbj@tail-f.com> wrote: > > > > > > > Ladislav Lhotka <lhotka@nic.cz> wrote: > > > >> Martin Bjorklund <mbj@tail-f.com> writes: > > > >> > > > >>> Hi, > > > >>> > > > >>> Here's yet another attempt to handle attributes in JSON, without > > > >>> changing the encoding for the case that there are no attributes > > > >>> present. > > > >>> > > > >>> In all examples, the attributes "inactive" and "etag" are present. > > > >>> > > > >>> Attributes are encoded differently depending on the type of object: > > > >>> > > > >>> > > > >>> leaf > > > >>> ---- > > > >>> > > > >>> Encode the attributes as a sibling to the leaf. > > > >>> > > > >>> > > > >>> leaf foo { > > > >>> type string; > > > >>> } > > > >>> > > > >>> "foo": "some value"; > > > >>> "@foo": { > > > >>> "inactive": true, > > > >>> "etag": "..."; > > > >>> } > > > >>> > > > >>> > > > >>> list instance > > > >>> ------------- > > > >>> > > > >>> Encode the attributes within the list instance. > > > >>> > > > >>> > > > >>> list bar { > > > >>> key name; > > > >>> leaf name { > > > >>> type string; > > > >>> } > > > >>> ... > > > >>> } > > > >>> > > > >>> "bar": [ > > > >>> { > > > >>> "@bar": { > > > >>> "inactive": true, > > > >>> "etag": "..." > > > >>> } > > > >>> "name": "instance name"; > > > >>> }] > > > >>> > > > >> > > > >> This could be ambiguous: > > > >> > > > >> list bar { > > > >> key name; > > > >> leaf name { ... } > > > >> leaf bar { ... } > > > >> } > > > >> > > > >> Then you don't know whether the attributes belong to the list entry > > > >> or to the contained leaf. > > > > > > > > Right. Then we use "@@bar" for the list / container attributes. > > > > > > OK, then this scheme is fine with me. > > > > > > > > Looks more complicated than other solution proposals. > > Do we agree that we don't want different encodings for values if there > are attributes or not? I.e., if my code works when no attributes are > present, it should also work if there are attributes? I am not sure even your encoding satisfies this requirement. At least your code has to be instructed to ignore the attribute stuff. > > > Not if the normal encoding is painful to use. > The use attributes is going to be rare. > I want the expected "plain" encoding when there are no attributes. > Code that generates JSON and does not care about attributes > must not be rendered useless because the JSON is specially encoded > in RESTCONF. We want to leverage wide knowledge of JSON, > not invent our own incompatible version of it. This is my preference, too. > > > If so, do we have any other proposal? Leave it to proponents of every use case to figure out ad hoc how to encode what’s needed, or resort to XML. Lada > > I am all for a simpler solution! > > > > Putting attributes at the sibling level does not work for leaf-lists. > Even for leafs, it is difficult to parse. JSON objects are unordered, > so the "@foo" could appear anywhere, even before "foo". The schemes > I proposed always keeps the attributes within the node for the attributes > (just like XML). > > One idea I had was to simply disallow attributes for leaf and leaf-list. > They can only go in container or list nodes. This is restrictive but then there > will not be any dual decoding possibilities. > > > > /martin > > Andy > -- Ladislav Lhotka, CZ.NIC Labs PGP Key ID: E74E8C0C
- [netmod] attributes in draft-lhotka-netmod-yang-j… Dean Bogdanovic
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman