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

Joe Hildebrand <> Thu, 18 February 2021 07:13 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 753B33A0C7E for <>; Wed, 17 Feb 2021 23:13:52 -0800 (PST)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -1.696
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: (amavisd-new); dkim=neutral reason="invalid (public key: not available)"
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id JDTP_zBX3gak for <>; Wed, 17 Feb 2021 23:13:48 -0800 (PST)
Received: from ( [IPv6:2607:f8b0:4864:20::c35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by (Postfix) with ESMTPS id 73F5D3A0C7D for <>; Wed, 17 Feb 2021 23:13:48 -0800 (PST)
Received: by with SMTP id n19so224036ooj.11 for <>; Wed, 17 Feb 2021 23:13:48 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; 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;; 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 with ESMTPSA id g13sm892882otl.60.2021. (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.\))
From: Joe Hildebrand <>
In-Reply-To: <>
Date: Thu, 18 Feb 2021 00:13:44 -0700
Content-Transfer-Encoding: quoted-printable
Message-Id: <>
References: <>
To: "Dale R. Worley" <>
X-Mailer: Apple Mail (2.3654.
Archived-At: <>
Subject: Re: [Cbor] Tag 279 "Map entries for CBOR" in array format
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-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 <> wrote:
> A recent message pointed to:
> 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