Re: [Cbor] Tag 279 "Map entries for CBOR" in array format

Joe Hildebrand <hildjj@cursive.net> Thu, 18 February 2021 07:13 UTC

Return-Path: <hildjj@cursive.net>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 753B33A0C7E for <cbor@ietfa.amsl.com>; Wed, 17 Feb 2021 23:13:52 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.696
X-Spam-Level:
X-Spam-Status: No, score=-1.696 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=neutral reason="invalid (public key: not available)" header.d=cursive.net
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 JDTP_zBX3gak for <cbor@ietfa.amsl.com>; Wed, 17 Feb 2021 23:13:48 -0800 (PST)
Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 73F5D3A0C7D for <cbor@ietf.org>; Wed, 17 Feb 2021 23:13:48 -0800 (PST)
Received: by mail-oo1-xc35.google.com with SMTP id n19so224036ooj.11 for <cbor@ietf.org>; Wed, 17 Feb 2021 23:13:48 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cursive.net; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=zLDUo6cOi9iXH1hw/5PvcTHGobEAx61Gihz91OZyNZM=; b=rYjX2Ka5yfzNoraludflBgozi5sdaOSRCvKkvwqEOLYvuCy807aMU4ASrxTdVxFjyq lclC2BIZSIvsh/F+ns5qJLo+VzBKOWA8Wn9zvl0MNde2YvzwGLqwvFTfGnzGGvLE0L2H sqqiO6EUfUDI1psPHNUjtF98tAy+SDD8Ru2cs=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=zLDUo6cOi9iXH1hw/5PvcTHGobEAx61Gihz91OZyNZM=; b=PxUvPOSTosNKNDKQgCey3HLXvQ4Pm68RoBVfkWTA3x8s5UOutSF4Yc+mX8FSiGTmEG C+5nr3ysuDOtcIP7Noa0TtJMQORDlUqIv2K6I6bCe7cwEEjPwTe5tS11Eu7wxCIPMFBp 34giQ04GkKEuBNgLE2FCq0vDwkd8Pyjoc2GVQD98JkFbvghszezlDJ2RywFHTHcb/XmJ fUvqkJa/TZ+K3HN88JpZEVieB6hAEwATnYZOvQiRRtdb8d0DL+EYuAPMLLdiiXXIEmhw QhLz+zfqEU1A+g9JgXutFDj4wqUJ1WatWl9AOkrwsJCLn4q8u+PUh1cim3owKMq7i+sp zKNw==
X-Gm-Message-State: AOAM530AcMQ0Hy8959tYESEayKJds2B4+ZEqiJDAZRTDSigSQhKrGIMr j5IMd3mVDlQVUfeMvAn+K3TCguZ9IUti3g==
X-Google-Smtp-Source: ABdhPJzS7dubgKl0Igh4qyMchzwB/AjwCA4tuwO4PPRs3g83jL5iD9I0KOjqzI4k4s8ex7kwPqlc/Q==
X-Received: by 2002:a4a:3f56:: with SMTP id x22mr2075716ooe.32.1613632427541; Wed, 17 Feb 2021 23:13:47 -0800 (PST)
Received: from ?IPv6:2601:282:200:3758:e949:7e4:81e3:ff71? ([2601:282:200:3758:e949:7e4:81e3:ff71]) by smtp.gmail.com with ESMTPSA id g13sm892882otl.60.2021.02.17.23.13.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Feb 2021 23:13:47 -0800 (PST)
Content-Type: text/plain; charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\))
From: Joe Hildebrand <hildjj@cursive.net>
In-Reply-To: <87tuqakown.fsf@hobgoblin.ariadne.com>
Date: Thu, 18 Feb 2021 00:13:44 -0700
Cc: cbor@ietf.org
Content-Transfer-Encoding: quoted-printable
Message-Id: <448DA93B-264D-4BC6-BCC3-22D2712CAFA6@cursive.net>
References: <87tuqakown.fsf@hobgoblin.ariadne.com>
To: "Dale R. Worley" <worley@ariadne.com>
X-Mailer: Apple Mail (2.3654.60.0.2.21)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/QUbNiWAO_8_peTP9tBfD_N50JDU>
Subject: Re: [Cbor] Tag 279 "Map entries for CBOR" in array format
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 18 Feb 2021 17:35:05 -0000

(Note that I just accepted a PR from Carsten, so the text has changed ever so slightly)

The main reason I want a type like this isn't to persevere order, but to round-trip Map instances from JavaScript, through CBOR, and back to JavaScript.  I want to ensure that they end up a Map again, even if they have all-string keys.  Node-cbor currently uses a JS Object if all of the keys are strings, and falls back to a Map if it detects anything other than a string.  Another choice would have been to always coerce CBOR map keys into strings, but that is a little difficult to do in a non-surprising way with structured keys.

That said, order doesn't hurt my use case, and if someone else wants that, great.

More comments, questions and pull requests welcome.

— 
Joe Hildebrand

> On Feb 17, 2021, at 8:58 PM, Dale R. Worley <worley@ariadne.com> wrote:
> 
> A recent message pointed to:
> 
>> https://github.com/hildjj/cbor-map-entries 
> 
> I found it an odd read, as I couldn't figure out what the point is.  As
> written, it's an alternative way to express maps, as a tag applied to an
> array containing keys and values.  But what's the point?
> 
> The text starts off with "Although CBOR has support for generic Maps
> (Major Type 5), some implementation languages (such as ECMAScript) have
> two different types they might use to hold the information, depending on
> whether all of the keys are strings or not."  And it makes sense that's
> a problem to be solved.  But this document doesn't solve that, in that
> neither tag-279-array nor CBOR map are constrained to have the keys be
> strings, so both of them would have to be decoded into a more general
> data type/structure.
> 
> Maybe I'm not read into CBOR enough to understand what is intended.  But
> it seems to me that this document probably intended to specify that the
> key values in a type-279-array must be strings.
> 
> Dale
> 
> _______________________________________________
> CBOR mailing list
> CBOR@ietf.org
> https://www.ietf.org/mailman/listinfo/cbor