Re: [Json] The names within an object SHOULD be unique.

Jorge Chamorro <jorge@jorgechamorro.com> Tue, 30 July 2013 18:13 UTC

Return-Path: <jorge@jorgechamorro.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 8579E11E8108 for <json@ietfa.amsl.com>; Tue, 30 Jul 2013 11:13:31 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.599
X-Spam-Level:
X-Spam-Status: No, score=-3.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, RCVD_IN_DNSWL_LOW=-1]
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 n8ko3-4yIHLB for <json@ietfa.amsl.com>; Tue, 30 Jul 2013 11:13:26 -0700 (PDT)
Received: from mail-we0-f170.google.com (mail-we0-f170.google.com [74.125.82.170]) by ietfa.amsl.com (Postfix) with ESMTP id 0D1D411E80F3 for <json@ietf.org>; Tue, 30 Jul 2013 11:13:25 -0700 (PDT)
Received: by mail-we0-f170.google.com with SMTP id w60so5499524wes.29 for <json@ietf.org>; Tue, 30 Jul 2013 11:13:25 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer :x-gm-message-state; bh=mSkg0Qj6fiQhqjW6Zn5Y+OSG5zxahHqf4W3KLoQhdOg=; b=aUzVOLnWEBfQiJS8BdH4OSQEgfYdkAQ6KOZAGTOBIKDKodAIckcziCu2iJ0wMyaiun kgvWODUb36ez++LqMlsn0p2b+EPFXMt0To9UiItVAOuFAWzNIHsvuL2Yi6NMtSC311WH e+f2gYDB4u5DI8G7Z+96p+zk0qs27nCaccV2qAn7lHrCw7QdqaO5yFSOzhqQzKs8/j1u mqzq5HstJUFAxftfPFoxIF6/7Ftc/z5vPZfUYgxZWltwI8z1QuBwDrGopWelMbDZFqgH c7lHrw/Ca6+RdB9faCb9mNRsdE93NKwyc1eJDYGDuXV80bTH6ShZdfJM4dOS2TwH1NQ0 VivQ==
X-Received: by 10.180.160.165 with SMTP id xl5mr1784281wib.46.1375208005088; Tue, 30 Jul 2013 11:13:25 -0700 (PDT)
Received: from [192.168.10.50] (134.Red-88-0-161.dynamicIP.rima-tde.net. [88.0.161.134]) by mx.google.com with ESMTPSA id s19sm30204219wik.11.2013.07.30.11.13.24 for <multiple recipients> (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Jul 2013 11:13:24 -0700 (PDT)
Mime-Version: 1.0 (Apple Message framework v1085)
Content-Type: text/plain; charset="us-ascii"
From: Jorge Chamorro <jorge@jorgechamorro.com>
In-Reply-To: <A723FC6ECC552A4D8C8249D9E07425A71416EFE8@xmb-rcd-x10.cisco.com>
Date: Tue, 30 Jul 2013 20:13:22 +0200
Content-Transfer-Encoding: quoted-printable
Message-Id: <5CA3F8DE-40FD-4B0E-B60F-7120E5127622@jorgechamorro.com>
References: <A723FC6ECC552A4D8C8249D9E07425A71416EFE8@xmb-rcd-x10.cisco.com>
To: Joe Hildebrand <jhildebr@cisco.com>
X-Mailer: Apple Mail (2.1085)
X-Gm-Message-State: ALoCoQkbl8QK7LTVh0hzDlRba+gjnBDhgS/maSIuTFyRRJpkulylFgVi4M8IWmYkalDIOH3rznhG
Cc: John Cowan <cowan@mercury.ccil.org>, "json@ietf.org WG" <json@ietf.org>
Subject: Re: [Json] 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: Tue, 30 Jul 2013 18:13:31 -0000

On 30/07/2013, at 16:11, Joe Hildebrand (jhildebr) wrote:

> On 7/30/13 1:11 PM, "Jorge Chamorro" <jorge@jorgechamorro.com> wrote:
> 
>> On 28/07/2013, at 05:46, John Cowan wrote:
>>> Jorge Chamorro scripsit:
>>> 
>>>> Yes, but it's problematic only for the streaming parsers that emit
>>>> [key,value] pairs, not for those which emit entire objects.
>>> 
>>> In what sense are they streaming parsers, then?  The whole idea of a
>>> streaming
>>> parser is that it passes along the elements of JSON objects, arrays, and
>>> perhaps even strings and numbers bit by bit to the invoking application.
>> 
>> Say you've got a stream (a pipe or a network connection) and a stream of
>> json-objects arriving through it, you may very well want the parser to
>> emit entire objects instead of its parts, no?
> 
> I've never seen an implementation that is both streaming and not streaming
> at the same time.  Can you say more about how you'd write the API for
> that?

Easy:

parser= CreateStreamingParser(stream, listener);

:-)

Whenever the parser's got a complete json-object, it simply calls listener(JSON.parse(json-object));

> Better, can you give an example of such an implementation?

There's a bunch, most use a delimiter (say \0) as a chunks boundary marker so that they can be stateless.

But some aren't stateless:
<http://www.chrisdew.com/blog/2013/06/11/json-stream-rfc-a-standard-for-delimiting-in-a-stream-protocol-tcp/>

There's also node.js' fork(), where communication between parents and children happens via "messages" that a are json.strigify()ed objects, via a pipe or a network connection.

The thing is, a streaming parser is one whose *input* is a stream, isn't it?

> If you mean an application that takes a stream of complete JSON objects
> without wrapping them in an array, that problem is likely out of scope,
> and the processor would act identically to a non-streaming implementation
> in our existing worldview.

That's why I said that duplicate keys complicate only those parsers that emit parts as soon as they arrive.
-- 
( Jorge )();