Re: [netmod] attributes in draft-lhotka-netmod-yang-json

Ladislav Lhotka <lhotka@nic.cz> Sun, 23 March 2014 16:15 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 F2B3D1A6FD6 for <netmod@ietfa.amsl.com>; Sun, 23 Mar 2014 09:15:01 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham
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 yQZL2UHlD419 for <netmod@ietfa.amsl.com>; Sun, 23 Mar 2014 09:14:57 -0700 (PDT)
Received: from trail.lhotka.name (trail.lhotka.name [77.48.224.143]) by ietfa.amsl.com (Postfix) with ESMTP id 8C1A01A6FC9 for <netmod@ietf.org>; Sun, 23 Mar 2014 09:14:57 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1]) by trail.lhotka.name (Postfix) with ESMTP id 6A7DF54050C; Sun, 23 Mar 2014 17:14:56 +0100 (CET)
Received: from trail.lhotka.name ([127.0.0.1]) by localhost (trail.lhotka.name [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Tq2TELY+oP7V; Sun, 23 Mar 2014 17:14:52 +0100 (CET)
Received: from localhost (unknown [172.29.2.202]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by trail.lhotka.name (Postfix) with ESMTPSA id 620B35402CD; Sun, 23 Mar 2014 17:14:51 +0100 (CET)
From: Ladislav Lhotka <lhotka@nic.cz>
To: Andy Bierman <andy@yumaworks.com>
In-Reply-To: <CABCOCHRZLp52pgMhi0tKs3=vLZLkAQcw=iK4TG77BArSCK8-_g@mail.gmail.com>
References: <3FADE5E8-88AC-4FD0-A2F6-72F408FAFFC4@juniper.net> <20140320.150426.496532825.mbj@tail-f.com> <CABCOCHT3AJR0u=-GV1eM8geL-F2j7HSBsw0uBb1DYDvZio6eCA@mail.gmail.com> <CABCOCHSM7CwAPFOZ4qzzTtTRRX0LWE2Gb+ZWzmDpwBGSKRGhOg@mail.gmail.com> <m2bnwy7j0c.fsf@nic.cz> <CABCOCHRFjzj40nWtckJRPCbxCMSwojadRh0rBb27qMRyHx8MHA@mail.gmail.com> <m2ob0xb697.fsf@nic.cz> <CABCOCHS0=fODFFaf_2kDZVcbGAd=BuvJXCpR5-K3uQFXy+PAsw@mail.gmail.com> <m2k3blar7e.fsf@nic.cz> <CABCOCHRZLp52pgMhi0tKs3=vLZLkAQcw=iK4TG77BArSCK8-_g@mail.gmail.com>
User-Agent: Notmuch/0.17~rc2+11~g2de8ce9 (http://notmuchmail.org) Emacs/24.3.50.2 (x86_64-apple-darwin13.0.0)
Date: Sun, 23 Mar 2014 17:14:49 +0100
Message-ID: <m2lhw0hoxy.fsf@nic.cz>
MIME-Version: 1.0
Content-Type: text/plain
Archived-At: http://mailarchive.ietf.org/arch/msg/netmod/dnLBJHJUDp_Y3hZw9uNuF_jUY7Y
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:15:02 -0000

Andy Bierman <andy@yumaworks.com> writes:
>
> Try the example I did where entry1 is owned by owner admin1 and entry2
> is owned by admin2.  I don't think this works.

{ "top": {
  "A": [
    { "@tagged-value": {
        "@owner": "admin1",
        "@value": {
          "id": "entry-1",
          "aa": [42, 19]
        }
      }
    },
    { "@tagged-value": {
        "@owner": "admin2",
        "@value": {
          "id": "entry-2",
          "aa": [99, 11]
        }
      }
    }
  ],
  "host-name": "router"
}

>
> This approach is way too complicated. The encoding scheme in the RESTCONF
> draft
> is easier to implement and it works for list and leaf-list siblings.
>

I think it is more difficult to parse. If you have a container "foo" in the data model, you cannot tell whether

"foo": { ... }

is the "native" container or the encoding of attributes, without first inspecting the contents of the object, i.e. looking whether any keys of its members start with "@".

In my encoding, the two alternatives can be distinguished immediately:

"foo": { ... }    (native container)

versus

"foo": {
  @tagged-value { ... }
}

Note also that in your example

   "host-name" : {
       "@protect" : "protect",
       "host-name" : "router"
   }

the value of the "@protect" attribute is irrelevant, and this is where my "property" encoding is IMO more elegant:

  "host-name" : {
    "@protect" : "router"
  }

My impression from previous discussions was that the proposed uses of XML attributes ("protect", "disable" etc.) are often of this type.

Lada

-- 
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C