[Json] Parser and encoder options (Re: The names within an object SHOULD be unique.)

Nico Williams <nico@cryptonector.com> Thu, 06 June 2013 22:54 UTC

Return-Path: <nico@cryptonector.com>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 8806221F96EF for <json@ietfa.amsl.com>; Thu, 6 Jun 2013 15:54:08 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.977
X-Spam-Level:
X-Spam-Status: No, score=-1.977 tagged_above=-999 required=5 tests=[AWL=-0.000, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ao1GLvxRaPCd for <json@ietfa.amsl.com>; Thu, 6 Jun 2013 15:54:03 -0700 (PDT)
Received: from homiemail-a25.g.dreamhost.com (caiajhbdcaid.dreamhost.com [208.97.132.83]) by ietfa.amsl.com (Postfix) with ESMTP id 7267721F9967 for <json@ietf.org>; Thu, 6 Jun 2013 15:54:03 -0700 (PDT)
Received: from homiemail-a25.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a25.g.dreamhost.com (Postfix) with ESMTP id F2B84678063 for <json@ietf.org>; Thu, 6 Jun 2013 15:54:02 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cryptonector.com; h= mime-version:date:message-id:subject:from:to:cc:content-type; s= cryptonector.com; bh=wRPwAuq0c2UushSskq65UODizMQ=; b=w1R1GgWE7Dn GbCx0y3bDbCcBbDGxsC/tTinifaXub9jmid7k2f1Oe44YYP2RcwjCfARl4wGnor+ WDKc1Mvkjqft+aSL6SEhpQ+ad7zAXdQRruLJ51+P6dYoO6QIgE++fSZlULpnF5Ly Z+2IWrI4wb8WiTJFdYiwb7o5eY9N0VPA=
Received: from mail-we0-f178.google.com (mail-we0-f178.google.com [74.125.82.178]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: nico@cryptonector.com) by homiemail-a25.g.dreamhost.com (Postfix) with ESMTPSA id A53CF678075 for <json@ietf.org>; Thu, 6 Jun 2013 15:54:02 -0700 (PDT)
Received: by mail-we0-f178.google.com with SMTP id u53so2587778wes.9 for <json@ietf.org>; Thu, 06 Jun 2013 15:54:01 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=xnhiDaLH6N5I+Y0aQZ90nnXkh673sfOs77X0Fu8YBm0=; b=YziGu2bsEHlNFVN98/NZ0ratvws0grcFN6KZooDTDURohYqmRfLVA35Pc9zyLTXbUg 0bCLr6a6eQFfDu3xDjDMTBx5w5Q3aqSaYZ4058eorFzQgTEs3MO4HzztHNfxz3g6a8wO Nksm4Fxa31PoIoB0ghVvRy+BGPPi9gXEV9j1YvpHST/xRxZ2dgVisFN8MSjMm6LRnJqk MAK2DF+BltFypR9Zk9jYRBnrEtTrNSGSfRjejct0B8qtTFpOwpCbwrCxU5dPYuBTujIg wtU5qS4pgluJIGc5nTJozZrKGUgkpLN59g5M6Nxv2oAwfGKuUDAV6ffZZi1nmgwzyD3q 9tjA==
MIME-Version: 1.0
X-Received: by 10.194.24.8 with SMTP id q8mr2513044wjf.81.1370559241064; Thu, 06 Jun 2013 15:54:01 -0700 (PDT)
Received: by 10.216.63.136 with HTTP; Thu, 6 Jun 2013 15:54:01 -0700 (PDT)
Date: Thu, 06 Jun 2013 17:54:01 -0500
Message-ID: <CAK3OfOieEdB0fQdc-iQ+Fpw6cB3L3=4kQ-WamCdxnh7VuZdFPw@mail.gmail.com>
From: Nico Williams <nico@cryptonector.com>
To: Douglas Crockford <douglas@crockford.com>
Content-Type: text/plain; charset="UTF-8"
Cc: "json@ietf.org" <json@ietf.org>
Subject: [Json] Parser and encoder options (Re: The names within an object SHOULD be unique.)
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/json>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 06 Jun 2013 22:54:08 -0000

On Thu, Jun 6, 2013 at 5:21 PM, Nico Williams <nico@cryptonector.com> wrote:
> Regarding comments, I thought we'd have to accept that JSON does not
> have comments, but since there's talk of extensions, and since we
> could (and many, many parsers do) have options that can default to off
> (unavailable), we might indeed want to consider a comments option.

I forgot to finish this thought, which is just as well as this one
should have a different Subject line, so now I've an excuse to change
it.

I could certainly imagine a parser that a) accepts parse options from
the application, b) has some of the following options regarding
duplicate names:

 - take first value
 - take last value
 - aggregate all the values into an array preserving the order in
which they were received
 - return an error on duplicate names
 - warn of duplicate names
 - detect duplicate names (for streaming parsers)
 - use probabilistic duplicate name detection (also for streaming parsers)

I think we should formalize the concept of options for parsers and encoders.

For example, it's common to have options for pretty printing JSON.
And there's been talk of extensions, so why not have some useful
extensions (like comments, or string join, like in C, for
pretty-printing purposes)?

We should also have a taxonomy for describing an implementation.
We've seen the need to distinguish between streaming and non-streaming
parsers.  (For now that's my only contribution to such a taxonomy.)

Nico
--