Re: [apps-discuss] Describing JSON document formats

Nico Williams <nico@cryptonector.com> Fri, 30 November 2012 21:25 UTC

Return-Path: <nico@cryptonector.com>
X-Original-To: apps-discuss@ietfa.amsl.com
Delivered-To: apps-discuss@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id B863821F841F for <apps-discuss@ietfa.amsl.com>; Fri, 30 Nov 2012 13:25:57 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.377
X-Spam-Level:
X-Spam-Status: No, score=-1.377 tagged_above=-999 required=5 tests=[AWL=-0.600, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, J_CHICKENPOX_38=0.6, J_CHICKENPOX_39=0.6]
Received: from mail.ietf.org ([64.170.98.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OtePBTXyQAI6 for <apps-discuss@ietfa.amsl.com>; Fri, 30 Nov 2012 13:25:56 -0800 (PST)
Received: from homiemail-a26.g.dreamhost.com (caiajhbdcaib.dreamhost.com [208.97.132.81]) by ietfa.amsl.com (Postfix) with ESMTP id 8323821F8232 for <apps-discuss@ietf.org>; Fri, 30 Nov 2012 13:25:56 -0800 (PST)
Received: from homiemail-a26.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a26.g.dreamhost.com (Postfix) with ESMTP id 4757CB806D for <apps-discuss@ietf.org>; Fri, 30 Nov 2012 13:25:56 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cryptonector.com; h= mime-version:in-reply-to:references:date:message-id:subject:from :to:cc:content-type; s=cryptonector.com; bh=C99W1PcRcRQiQut2qHQU fmVUuH4=; b=FAMfPn5x0aWihAG2Optlc2Ma091QHk2yolBTBhetULLQK+M9qWcP HqM2y6yj30BziOIoIJgClLmdJ7oogNWJWzVIXLr9D0On8KR4vRHhtiwKzMervVCm FrXlP5UBz/HrORF2BQy3zQ2FiGlnKOfreVxDvEeaBxbNIrWwmG1zqh0=
Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: nico@cryptonector.com) by homiemail-a26.g.dreamhost.com (Postfix) with ESMTPSA id C90BEB806B for <apps-discuss@ietf.org>; Fri, 30 Nov 2012 13:25:55 -0800 (PST)
Received: by mail-wi0-f174.google.com with SMTP id hm9so6247241wib.13 for <apps-discuss@ietf.org>; Fri, 30 Nov 2012 13:25:54 -0800 (PST)
MIME-Version: 1.0
Received: by 10.216.142.85 with SMTP id h63mr929054wej.83.1354310754335; Fri, 30 Nov 2012 13:25:54 -0800 (PST)
Received: by 10.216.192.207 with HTTP; Fri, 30 Nov 2012 13:25:54 -0800 (PST)
In-Reply-To: <CAMm+Lwjeu_J7WP5EsGgLYn=k7-toGNaWy+sgUkivAiEetpb3Xg@mail.gmail.com>
References: <26263E0AC2BA16FFBE9930DE@caldav.corp.apple.com> <CAMm+Lwg9T318a+C7kip76Vy6yb76pkcXQquipz2Ez84sfn+vyg@mail.gmail.com> <CAK3OfOirrSY463nB4h1s8sRFetYwRNduuCtw9-4sSQZ6w=SdVg@mail.gmail.com> <CAMm+Lwjeu_J7WP5EsGgLYn=k7-toGNaWy+sgUkivAiEetpb3Xg@mail.gmail.com>
Date: Fri, 30 Nov 2012 15:25:54 -0600
Message-ID: <CAK3OfOhGGVoxQ5N==GpgXWEjt+-78yOq7UuXxKiTdzsnUFKB8Q@mail.gmail.com>
From: Nico Williams <nico@cryptonector.com>
To: Phillip Hallam-Baker <hallam@gmail.com>
Content-Type: text/plain; charset="UTF-8"
Cc: IETF Apps Discuss <apps-discuss@ietf.org>
Subject: Re: [apps-discuss] Describing JSON document formats
X-BeenThere: apps-discuss@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: General discussion of application-layer protocols <apps-discuss.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/apps-discuss>, <mailto:apps-discuss-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/apps-discuss>
List-Post: <mailto:apps-discuss@ietf.org>
List-Help: <mailto:apps-discuss-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/apps-discuss>, <mailto:apps-discuss-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 30 Nov 2012 21:25:57 -0000

On Fri, Nov 30, 2012 at 1:46 PM, Phillip Hallam-Baker <hallam@gmail.com> wrote:
> On Fri, Nov 30, 2012 at 1:45 PM, Nico Williams <nico@cryptonector.com>
> wrote:
>> Well, type constraints are a good thing.  If you know that some number
>> will be 0..2^32 - 1 then you can use a uint32_t in a C implementation
>> -- at least you'll want to distinguish between integer sizes, bignums,
>> and so on.  Yeah, you don't need min/max to convey integer size.
>
> Representation constraints are useful, agreed.
>
> But these can be 8, 16, 32, 64 or BIgNum, signed or unsigned.

Sure.  Note that this can be done in ASN.1:

UInt32 ::= Integer (0..4294967295)

but that sort of thing kinda needs to be standard in order to function
properly as compiler hints.

> Agree on the languages and willing to contribute a compiler that can
> generate code for any of them.

I'd be willing to contribute to an open source compiler.  Since I like
ASN.1 and have contributed (minor stuff) to the Heimdal ASN.1
compiler, one idea that comes to mind is to have a JASN->ASN.1
transformation and then use ASN.1 compilers where one has them.

> Just got to get my ass into gear and work out how to use GIT in visual
> studio.

http://stackoverflow.com/questions/507343/using-git-with-visual-studio

>> But, really, something ASN.1-ish, minus the awful syntax, minus the
>> tags, and all that.  We might call it JASN, say (heh).
>
> Why limit it to JSON, can generate a subset of XML and ASN.1 as well.

Well, I didn't want to go there (given the animosity to ASN.1 'round
these parts), but IMO there's been nothing really new under the sun in
data encoding since S-expressions.  There have been new things
regarding data handling (XPath and XSLT, though I also like to think
that these are [very, very awesome] generalizations of LISP features
like destructuring-bind).  But abstract syntax notations are all
roughly equivalent.  Existence proof: XER and FastInfoSet.  (Even XDR
is really a subset of ASN.1 paired with a form of PER that is 4-octet
aligned and with some minor differences in the encoding of
absent/defaulted fields.)

So, yes: this JASN thing should be able to generate proper ASN.1.

One of the nice things about using JSON for the syntax is that it
should be naturally extensible.  If we start with a syntax geared for
just JSON today, then later want to be able to generate arbitrary
ASN.1, we'll need to be able to specify tags and such, and... that's
just new fields that old JASN parsers can just ignore.

> XML Scema was sufficiently bjorked that when I was writing the SAML spec I
> had to use a tool to generate the XML schema from something sensible.

I know, but really, XML Schema can be mapped onto what you want
anyways.  It's just more useful to have a syntax that more simply maps
onto programming language types to represent the same data.


> > [...]
>
> Ah now here we get to a pet peeve of mine. Extensibility. I don't think any
> of the protocols I have worked on has really had a good model.

No?  Kerberos has been extended extensively over the years -- it's not
been perfect, but it has worked out.

> The extensibility mechanisms in XML work fine for documents. For protocols
> they are a #$()WQFE&QWE #$$# !!!! pain in the ass. They just don't work and
> xxx:namespace yyy:prefixes are stupid.

Agreed.  For protocols we almost never need namespaces the way we do
for documents.

> [Validation stuff elided.]
>
> My problem is that none of the schema validation attributes has been
> sufficient for input validation. If I have a data item representing a cheque
> then the important thing is that the payment is less than the balance on
> that account, not that it is less than some static value in a schema.

That's semantic validation.  Yeah, it can't be done with an abstract
syntax like ASN.1 or XML Schema.  (One might here mention ITU-T's SDL,
but that's never been used in the IETF, there's no toolkits, and SDL
is borked anyways by being case-insensitive, which renders it
incompatible with ASN.1.)

> I agree that data input validation is important, just don't see that static
> schema constraints help.

Well, for config files it's a lot better than nothing, but yes, it
doesn't go far enough.

Nico
--