Re: [netmod] attributes in draft-lhotka-netmod-yang-json
Andy Bierman <andy@yumaworks.com> Sun, 23 March 2014 16:06 UTC
Return-Path: <andy@yumaworks.com>
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 28D961A6FD4 for <netmod@ietfa.amsl.com>; Sun, 23 Mar 2014 09:06:25 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.278
X-Spam-Level:
X-Spam-Status: No, score=-1.278 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] 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 sCC2GQJmr7Cz for <netmod@ietfa.amsl.com>; Sun, 23 Mar 2014 09:06:22 -0700 (PDT)
Received: from mail-qg0-f47.google.com (mail-qg0-f47.google.com [209.85.192.47]) by ietfa.amsl.com (Postfix) with ESMTP id 08F071A0993 for <netmod@ietf.org>; Sun, 23 Mar 2014 09:06:21 -0700 (PDT)
Received: by mail-qg0-f47.google.com with SMTP id 63so13553410qgz.6 for <netmod@ietf.org>; Sun, 23 Mar 2014 09:06:21 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=T8gqtMfGfHNMFhcicxLQTJQY0Eed6pHl5LUZ3aBaEjk=; b=dy7nL0FtM00OWQjWdeyt42nrUl+5H8WE7oAdsvTIOJnsaFt30hKVFFdF/wbjdKkWY6 2OQqJOOi/DU96xT5/MY3SC9dHxMLSRhEHdGSts/G9vE2x+jA7dYchIsCYGMlilXDUPE2 f6ggLmaIwo0ag6jm4ABlwkoq4dW49JRbxWMCf0+XL+PTPiUXid8lddKG59LZpdn5dCZB 0esu2UAV1rK6cFxx1olXKD8xBnEi+36AC+BLib1Q498fEYbsTGnucTaNeroYBwRZosiL YFTR28aEhLc2uXYn2fIzaL3LGk47+XuMcYoNvsacd0molJ39/H6Y4CjSQAyiBT0syqnB 6SYA==
X-Gm-Message-State: ALoCoQlfl68Np14PqSKY9gegQl9XEqcK85gUCjF+sj4jBQ3ffmShYb3yjW+jAy64BqcHUbTnLsCA
MIME-Version: 1.0
X-Received: by 10.229.139.199 with SMTP id f7mr70102298qcu.2.1395590781332; Sun, 23 Mar 2014 09:06:21 -0700 (PDT)
Received: by 10.140.104.194 with HTTP; Sun, 23 Mar 2014 09:06:21 -0700 (PDT)
In-Reply-To: <m2ha6paqd3.fsf@nic.cz>
References: <m2bnwy7j0c.fsf@nic.cz> <CABCOCHRFjzj40nWtckJRPCbxCMSwojadRh0rBb27qMRyHx8MHA@mail.gmail.com> <m2ob0xb697.fsf@nic.cz> <20140323.110741.449355686.mbj@tail-f.com> <m2ha6paqd3.fsf@nic.cz>
Date: Sun, 23 Mar 2014 09:06:21 -0700
Message-ID: <CABCOCHTo9sWr2ojpwZ=zPowdxn5-PhxFnU+unzkoEmv7jY0PYw@mail.gmail.com>
From: Andy Bierman <andy@yumaworks.com>
To: Ladislav Lhotka <lhotka@nic.cz>
Content-Type: multipart/alternative; boundary="001a11c3e454c62ef704f5484c0f"
Archived-At: http://mailarchive.ietf.org/arch/msg/netmod/Jh5fAD-2kGNOcXFMT5FCuh31jxI
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: Sun, 23 Mar 2014 16:06:25 -0000
On Sun, Mar 23, 2014 at 8:26 AM, Ladislav Lhotka <lhotka@nic.cz> wrote: > Martin Bjorklund <mbj@tail-f.com> writes: > > > Ladislav Lhotka <lhotka@nic.cz> wrote: > >> Andy Bierman <andy@yumaworks.com> writes: > >> > >> ... > >> > >> > > >> > The attribute mapping needs to correspond to the XML attribute > mapping. > >> > Attributes have string values, so the mapping above will not work. > >> > >> I don't understand. XML schemas can define attribute values to be of > other > >> types, too, not only string. > >> > >> > > >> > Attributes can be qualified or unqualified. If qualified, then the > >> > module-name > >> > is used as a prefix: > >> > > >> > "foo" [ 1, 2, { "@foo-mod:owner":"admin1", "foo":3}, { > >> > "@foo-mod:owner":"admin2", "foo":4}, > >> > > >> > > >> > This approach presumes the attribute has a YANG module name that > defines > >> > the attribute, > >> > which is of course not allowed. > >> > > >> > RFC 6241 defines XML attributes for the <get> operation, using a hack > >> > called the 'get-filter-element-attributes' extension. > >> > > http://www.netconfcentral.org/modules/ietf-netconf/2011-06-01#get-filter-element-attributes.56 > >> > >> This is another extension that violates the rule stated in RFC 6020, > >> sec. 6.3.1: > >> > >> If a YANG compiler does not support a particular extension, which > >> appears in a YANG module as an unknown-statement (see Section 12), > >> the entire unknown-statement MAY be ignored by the compiler. > >> > >> > > >> > The NETCONF-EX <get2> operation has a "with-metadata" parameter that > uses > >> > identities > >> > to map attributes to YANG. > >> > > >> > I think a standard mechanism is needed to properly map attributes to > JSON > >> > and XML. > >> > >> I'd suggest to define two generic constructs: > >> > >> 1. Metadata > >> > >> Every JSON value (false / null / true / object / array / number / > string) can > >> be changed into a "@tagged-value" object, e.g. the number 42 can become > >> > >> { > >> "@tagged-value" : { > >> "@owner": "admin1", > >> "@value": 42 > >> } > >> } > >> > >> Multiple metadata key-value pairs may be present inside the > "@tagged-value" > >> object. > >> > >> 2. Properties > >> > >> For a property "foo", every JSON value can be changed into a "@foo" > object, > >> e.g. > >> > >> { > >> "@foo": 42 > >> } > >> > >> Such property objects may nest, e.g. > >> > >> { > >> "@bar": > >> { > >> "@foo": 42 > >> } > >> } > >> > >> Both constructs work for list and leaf-list entries, and may be also > combined. > > > > This makes both client and server programming much more complex. The > > whole point of using JSON is supposedly that it maps well to built-in > > datastructures in modern languages. This property makes parsing > > trivial, and makes it easy to get values. For example: > > > > res = json_parse(...) > > if res['ssh']['enabled']: > > ... > > > > now, with the proposed encoding, I have to be prepared for 'ssh' being > > a '@tagged-value', and '@enabled' being a tagged-value, and > > combinations thereof: > > > > if res['ssh']['enabled'] > > or res['@tagged-value']['ssh']['enabled'] > > or res['@tagged-value']['ssh']['@tagged-value']['enabled'] > > or ... > > > This seems to be a problem in every proposal. In the RESTCONF approach, a leaf will either be a simple type or an object. I think the other 2 proposals alter objects even more, but to an application, moving data at all introduces complexity. Your comment assumes a plain JSON parser is going to parse this text into a plain object. A plain XML parser knows about attributes, but in JSON they are not handled special. There is no way to introduce attributes into JSON in a way that will be special handled by a plain JSON parser. > As I write this I realize that I don't really understand your > > proposal..., so the code above is not correct - but the point is the > > same; as soon as you allow multiple encodings you make coding much > > more complex. > > I don't know whether the "enabled" parameter is a node in the data model > or a global attribute that can be added to any instance. Show me the > intended XML encoding. > > What I was trying to achieve was to be able to turn any JSON value into an > object where the value is present together with any number of tags. > > Please check the examples in my response to Andy (and maybe ignore the > "property" thing for the time being, it is just an optimization for a > special case). > > > > > Maybe the original JSON mapping idea is the only one that works; i.e., > > map pure YANG data to JSON. No meta data. A protocol that needs meta > > data should not use JSON; use XML instead. > > I tend to agree, and that's why I've been relucant to address attributes > in the draft. For "pure" YANG-based data JSON is an excellent fit (IMO > better than XML) and some applications should be just fine with it. > > Dump Attributes? Cons: Protocols are going to find a need for meta-data, like with-defaults. A complete lack of meta-data might lead to solutions like the "enabled" leaf in some YANG modules -- a common property is spread across the data model in ad-hoc fashion. Simply adding the meta-data into the reply (but not in the schema) will mess up a parser not expecting the extra leafs. Pros: We should try to keep the work scope bounded by real requirements. RESTCONF has no operations that use attributes. It is only supported in case vendors add their own meta-data somehow. HTTP meta-data is returned in header lines, not within the message body. I would be OK with forbidding attributes in RESTCONF. Not so keen about using XML for 1 set of RESTCONF features and JSON for a different set of RESTCONF features. Lada > > > > > > > /martin > > Andy
- [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