Re: [apps-discuss] Concise Binary Object Representation (CBOR)

Nico Williams <> Sat, 25 May 2013 03:29 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id D409521F944F for <>; Fri, 24 May 2013 20:29:03 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -1.371
X-Spam-Status: No, score=-1.371 tagged_above=-999 required=5 tests=[AWL=-0.394, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, J_BACKHAIR_33=1]
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id PXoT8bFB-Gv5 for <>; Fri, 24 May 2013 20:28:58 -0700 (PDT)
Received: from ( []) by (Postfix) with ESMTP id DB4A921F9339 for <>; Fri, 24 May 2013 20:28:58 -0700 (PDT)
Received: from (localhost []) by (Postfix) with ESMTP id 6B4DF438079 for <>; Fri, 24 May 2013 20:28:58 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed;; h= mime-version:in-reply-to:references:date:message-id:subject:from :to:cc:content-type;; bh=YEBFX4lHvSHP+qktLDI2 Pl5dR8E=; b=Y1BlM6jpxVvjY7sTUrv2xVNnzw+XKaKVYRMnN9tkhlFK8eWLWTzT gOWf3AdtARhRduzUgidxkh6CI+M3Eh6wFT2rkcxslmBVZLhY2l++DH5MqY3CEd2/ gqP9rqvb2uCC421SnuKgVseuNle7xaWnal4fExkza3PB6ndgr6Gtldo=
Received: from ( []) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: by (Postfix) with ESMTPSA id 1ACF643806C for <>; Fri, 24 May 2013 20:28:57 -0700 (PDT)
Received: by with SMTP id m6so228359wiv.17 for <>; Fri, 24 May 2013 20:28:56 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=iWiQaXgtQigqBfIS1ljAkbU0AuTGJ4+3MpxeVVm+AZU=; b=ZcGPO3s394YhBpWV6C4yE+Gt6SugUCwMmFv3kFckbGpQaz9f63OSIJSTAKI9CTNbkd bq6+nojyW5D1Nk0xdi6Pm4SSDeifTO9oollxk+iSBQeMX58fX8ydevUgXL/MpqHI06GU qJFslWgLFUTZ3iNnNmFU91WAGkO0aBAandyQCll5BNZakEzm1MoUft04DIx9yow7CuMK PBHWMf2lAEkLpPqYlXl11Ez+r/E8Q4wMicbruxQV+tsrZdt5BvGTAUyfCk3t28xoplvO iJiRw8SsLCP93dCcWO0vbOyz1ajjOTJp9k0offoyU/UH/u08ejgib2ykqgCKLDpn6Nlw WZqg==
MIME-Version: 1.0
X-Received: by with SMTP id q2mr1535092wjw.34.1369452536497; Fri, 24 May 2013 20:28:56 -0700 (PDT)
Received: by with HTTP; Fri, 24 May 2013 20:28:56 -0700 (PDT)
In-Reply-To: <>
References: <>
Date: Fri, 24 May 2013 22:28:56 -0500
Message-ID: <>
From: Nico Williams <>
To: Paul Hoffman <>
Content-Type: text/plain; charset="UTF-8"
Subject: Re: [apps-discuss] Concise Binary Object Representation (CBOR)
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: General discussion of application-layer protocols <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Sat, 25 May 2013 03:29:03 -0000

Thinking about what *I* want in a binary JSON encoding, and taking
into account PHB's points about online encoding and decoding, all I
really want, the one thing I badly want, is counted-bytes and chunked
Unicode and octet strings.  That's it.  So picture JSON, complete with
square and curly brackets, but no commas nor colons, just strings
(byte-counted or chunked), some encoding for numbers, booleans, and
null.  It's the handing of scalars that sucks about JSON: string
escaping, number printing and parsing.

Something like this:

{<Unicode string of length 3>foo<Unicode string of length 3>bar<join
to preceding string, length 3>baz<Unicode string of length
3>num<integer value 5>}

as an encoding of { "foo": "barbaz", "num": 5 }, with "barbaz" chunked.

One of the nice things about such an encoding is that it should be
possible to implement as a fairly small variation on existing code:
it's almost only a different way of encoding scalar types -- the only
other difference being that commas and colons are not needed.

With a variable-length encoding of integers and IEEE 754 64-bit
doubles for reals... that's compact enough.  Not nearly as compact as
we could get with schemas and PER-like encodings, but good enough for
a schema-less encoding.