Re: [apps-discuss] JSON Pointer syntax

James M Snell <jasnell@gmail.com> Thu, 20 September 2012 16:25 UTC

Return-Path: <jasnell@gmail.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 4235B21F87FF for <apps-discuss@ietfa.amsl.com>; Thu, 20 Sep 2012 09:25:07 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.056
X-Spam-Level:
X-Spam-Status: No, score=-2.056 tagged_above=-999 required=5 tests=[AWL=-1.324, BAYES_00=-2.599, HTML_MESSAGE=0.001, J_CHICKENPOX_51=0.6, J_CHICKENPOX_53=0.6, RCVD_IN_DNSWL_LOW=-1, SARE_HTML_USL_OBFU=1.666]
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 esW2rZ+uaAH4 for <apps-discuss@ietfa.amsl.com>; Thu, 20 Sep 2012 09:25:06 -0700 (PDT)
Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) by ietfa.amsl.com (Postfix) with ESMTP id B239321F87FA for <apps-discuss@ietf.org>; Thu, 20 Sep 2012 09:25:05 -0700 (PDT)
Received: by wgbdr13 with SMTP id dr13so390163wgb.13 for <apps-discuss@ietf.org>; Thu, 20 Sep 2012 09:25:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=MXJ9eZ0KZhJbDIRI9Fz8NMnSNDF/A23JkfYcWMRnyvs=; b=ug2CgMcVHZCEPL10JvFgMBbS/49kFnaQJ8RzCR0OH98XawREKnjMMpm2gi5EpB+Nk3 kbXntIqTYiSt9TtQ4R3pLUkZBdLykz2+9nZoHdSRqEyrgdqVDj/rcTD+N906FjHlJeZB SpymYIIV/aqhqO4c/CB0ZPcAlog8rEmxZVCmfPcfL9IT4NC7T6KjZNYBCChWfWvP9GIe lNoEkoWKce4s5tJjbaor/7JWSSm9CT2LxOZNy35sYqt7q0uYEuV7PVlmi5j17pYvT1Pa F225Pmidhna/pVgHzTP5S8BHRPHg7xVOzX/PbMEukZ8AsH8xdut34LFyi2cIhWjaFYqV ySig==
Received: by 10.180.97.33 with SMTP id dx1mr5494134wib.18.1348158304739; Thu, 20 Sep 2012 09:25:04 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.223.182.4 with HTTP; Thu, 20 Sep 2012 09:24:44 -0700 (PDT)
In-Reply-To: <505B3291.4060907@gmx.de>
References: <5059E1E8.6040704@status.net> <CALcybBDThJqCMt-zVfodxc0AW78-pmxD_JdM8nqOjsfiKJaDmw@mail.gmail.com> <5059ED76.50202@status.net> <1348077337.2880.3.camel@polyglot> <505AF1AA.6080601@status.net> <CAMm+LwhO5jgu6afx0Kdpyd_34LhCY4w62DZnzLOwL7PtupwkfA@mail.gmail.com> <505B194D.9080002@gmx.de> <CAMm+LwjWuApmK8cz-WpUpXUctq0pHvoKwLZZpCDoXGTV43qPsg@mail.gmail.com> <505B2513.8000900@gmx.de> <CAMm+LwiuJHTsHjBw2e80NgEdccxSinR-PvVeu5zOd6+aP7CdNg@mail.gmail.com> <505B3291.4060907@gmx.de>
From: James M Snell <jasnell@gmail.com>
Date: Thu, 20 Sep 2012 09:24:44 -0700
Message-ID: <CABP7RbemcpC-Ua_x-qxkGYNo3QW807idjD8KgQP69tBk-H8d+w@mail.gmail.com>
To: Julian Reschke <julian.reschke@gmx.de>
Content-Type: multipart/alternative; boundary="f46d04428f0cdadfbe04ca249050"
Cc: "apps-discuss@ietf.org" <apps-discuss@ietf.org>
Subject: Re: [apps-discuss] JSON Pointer syntax
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: Thu, 20 Sep 2012 16:25:07 -0000

On Thu, Sep 20, 2012 at 8:13 AM, Julian Reschke <julian.reschke@gmx.de>wrote:

>
>>         Yes, it does consider:
>>
>>         { "alice" : { "bob" : [ 10, 20, 30] } }
>>
>>
>>         Let us imagine we have code that is stepping through each
>>         element of an
>>         array using an index i. The path looks like  alice.bob.i
>>
>>
Huh? If we're iterating through this using JavaScript code it would be
something like

  for (i in m.alice.bob)
    print(m.alice.bob[i]

If I was going to use a JSON Pointer to iterate through, it would look like

  for (i in m.alice.bob)
    print(eval_pointer( "m.alice.bob." + i ))


         Iterating the loop produces 10, 20, 30
>>
>>         When evaluating that expression in a scripting language or such
>>         we have
>>         alice and bob which are tag names and we have i which is a bound
>>         variable being used as an index. That leads to confusion.
>>
>>
I'm sorry, but there is no confusion when the code example actually makes
sense. No disrespect intended, but the example you give here, Phil, does
not appear to make much sense.


>         Now imagine that mallet knows that the index variable used is i,
>> she
>>         creates the following message:
>>
>>
>>         { "alice" : { "bob" : [ 10, 20, 30] , "i" : 42 } }
>>
>>         Depending on the implementation the iteration may now produce
>>         10, 20, 30
>>         as before or 42 or even 42, 42, 42.
>>
>
> How so? There's is only one object named "alice.bob" here, and it is an
> array. There's also "alice.i", but how does that matter?
>
>
The full set of valid JSON Pointers I see in this example are:

  /alice
  /alice/bob
  /alice/bob/0
  /alice/bob/1
  /alice/bob/2
  /alice/i

Which in dot notation, of course, would be:

  alice
  alice.bob
  alice.bob.0
  alice.bob.1
  alice.bob.2
  alice.i

I see absolutely no confusion here.


>  [snip]
>
>> I am asking questions of interpretation here and your response is always
>> 'go read the spec'. Well that is the whole issue, the spec is not clear
>> and it cannot be clear on this issue unless it raises it and addresses
>> it as a specific case.
>>
>> If people can't explain how a spec should be interpreted then the spec
>> fails.
>>
>>
Yes.. and again, no disrespect intended here Phil, but I think the issue at
hand right now is that, so far, none of the examples and feedback you have
provided, thus far, have made any sense at all.


> [snip]
>
>          No, it is RESERVED as in do not use it after the query.
>>
>>         We are not talking about a change to the HTTP URL spec here. So
>>         we MUST
>>         NOT use that character. It is out of bounds.
>>
>>
>>     BS. Nobody is proposing to change the URI syntax, which happens to
>> say:
>>
>>         query       = *( pchar / "/" / "?" )
>>
>>
>> It goes on to say:
>>
>> The characters slash ("/") and question mark ("?") may represent data
>> within the query component. Beware that some older, erroneous
>> implementations may not handle such data correctly when it is used as
>> the base URI for relative references (Section 5.1
>> <http://greenbytes.de/tech/**webdav/rfc3986.html#base-uri<http://greenbytes.de/tech/webdav/rfc3986.html#base-uri>
>> >)**, apparently
>>
>> because they fail to distinguish query data from path data when looking
>> for hierarchical separators. However, as query components are often used
>> to carry identifying information in the form of "key=value" pairs and
>> one frequently used value is a reference to another URI, it is sometimes
>> better for usability to avoid percent-encoding those characters.
>>
>> This would not be something I would see as critical if there was not
>> another choice here.
>>
>
> I don't see it as critical.
>
>
>  Probably the safest approach is to permit either separator to be used in
>> the path expression and make them interchangeable which is what we did
>> with " and '.
>>
>
> I don't believe that allowing two different notations is actually helpful.
>
>
+1 .. Pick One.

>
>  That still leaves the question of what to do with []. It looks like they
>> should be safe but it is something I would want to see tested.
>>
>
> That would be relevant if JSON Pointer actually needed them. They are in
> RFC 3986's gen-delims, so strict URI parsers are likely to be unhappy when
> seeing them in unescaped form (in the wrong place).
>
>
I have run into a number of very real issues in various places with the use
of errant square brackets in query string parameters and fragment
identifiers. 3986 is actually quite clear on the fact that square brackets
are ONLY allowed when delimiting IPv6 addresses.

Specifically, section 3.2.2:

   A host identified by an Internet Protocol literal address, version 6
   [RFC3513] or later, is distinguished by enclosing the IP literal
   within square brackets ("[" and "]").  This is the only place where
   square bracket characters are allowed in the URI syntax.

I'll say again that I personally prefer the JavaScript notation, even with
square brackets and I don't generally see a problem with escaping those
within the URI. But the square brackets are not strictly required to make
things work. The existing / delimited syntax does work in practice and it's
simple to implement.

- James


> Best regards, Julian
>
>
> Best regards, Julian
>
> ______________________________**_________________
> apps-discuss mailing list
> apps-discuss@ietf.org
> https://www.ietf.org/mailman/**listinfo/apps-discuss<https://www.ietf.org/mailman/listinfo/apps-discuss>
>