Re: [apps-discuss] JSON Patch

Julian Reschke <julian.reschke@gmx.de> Fri, 25 November 2011 13:05 UTC

Return-Path: <julian.reschke@gmx.de>
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 AB66A21F8C11 for <apps-discuss@ietfa.amsl.com>; Fri, 25 Nov 2011 05:05:12 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -103.645
X-Spam-Level:
X-Spam-Status: No, score=-103.645 tagged_above=-999 required=5 tests=[AWL=-1.646, BAYES_00=-2.599, J_CHICKENPOX_14=0.6, USER_IN_WHITELIST=-100]
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 JigR8Lxptm9f for <apps-discuss@ietfa.amsl.com>; Fri, 25 Nov 2011 05:05:12 -0800 (PST)
Received: from mailout-de.gmx.net (mailout-de.gmx.net [213.165.64.22]) by ietfa.amsl.com (Postfix) with SMTP id E482921F8C08 for <apps-discuss@ietf.org>; Fri, 25 Nov 2011 05:05:06 -0800 (PST)
Received: (qmail invoked by alias); 25 Nov 2011 13:05:05 -0000
Received: from mail.greenbytes.de (EHLO [192.168.1.140]) [217.91.35.233] by mail.gmx.net (mp064) with SMTP; 25 Nov 2011 14:05:05 +0100
X-Authenticated: #1915285
X-Provags-ID: V01U2FsdGVkX19aCKNcFHla2LV0m3Cw4eOihr3QztRsPOXzKRP0+t TcHF2dNPOwA31R
Message-ID: <4ECF927D.4070809@gmx.de>
Date: Fri, 25 Nov 2011 14:05:01 +0100
From: Julian Reschke <julian.reschke@gmx.de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0
MIME-Version: 1.0
To: "Manger, James H" <James.H.Manger@team.telstra.com>
References: <4EB1482E.1040600@adobe.com> <4EB14C2E.8040208@gmx.de> <1320254564.2622.37.camel@neutron> <4EBBA0DD.9020605@gmx.de> <4ECBC843.60900@gmx.de> <255B9BB34FB7D647A506DC292726F6E113884047C4@WSMSG3153V.srv.dir.telstra.com> <CABkgnnWMWL43cjBYpXP2tfxUCwLbt5Q2hYvBvtK3A6BKKhm=BA@mail.gmail.com> <4ECDEEC4.3050007@it.aoyama.ac.jp> <255B9BB34FB7D647A506DC292726F6E113885C474E@WSMSG3153V.srv.dir.telstra.com>
In-Reply-To: <255B9BB34FB7D647A506DC292726F6E113885C474E@WSMSG3153V.srv.dir.telstra.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Y-GMX-Trusted: 0
Cc: "apps-discuss@ietf.org" <apps-discuss@ietf.org>
Subject: Re: [apps-discuss] JSON Patch
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, 25 Nov 2011 13:05:12 -0000

On 2011-11-25 02:58, Manger, James H wrote:
>>> <James.H.Manger@team.telstra.com>   wrote:
>>>> On escaping: how about replacing every '/' in an object member's name with the Unicode REPLACEMENT CHARACTER U+FFFD when creating a JSON pointer.
>
>> On 2011/11/24 11:08, Martin Thomson wrote:
>>> Interesting that you choose U+FFFD in the same way that backslash was
>>> chosen as an escape character in the first place.  I'm not a big fan
>>> of that approach.
>
> On 2011/11/24, Martin J. Dürst wrote:
>> Yes, please don't. The semantics of U+FFFD is mostly a character that
>> wasn't successfully converted from some other encoding. Overloading that
>> with "escaping a slash" is a bad idea.
>
> JSON pointer theoretically needs a proper escaping mechanism since it reserves 1 char as a delimiter. However, choosing 1 char not to support avoids a fair amount of inevitable confusion and complexity. I chose U+FFFD REPLACEMENT CHARACTER. If you don’t like that choice, how about U+001F INFOMATION SEPARATOR ONE.

I like that; it avoids adding a whole new escaping sequence, and I think 
it's ok to sacrifice compatibility with identifiers that contain control 
characters.

> Not supporting pointers for names with, say, a U+FFFD char is not ideal but hinders almost no practical uses.
> Escaping '/' with '\/' could be worse. It seems certain to cause significant confusion. You can no longer simply split a pointer on '/' characters, but need to use, say, a regular expression to parse a pointer. A / can be legitimately escaped in a JSON string as "\/", and apparently often is [http://stackoverflow.com/questions/1580647/json-why-are-forward-slashes-escaped] so developers will read and write 0, 1, 2, or 3 backslashes (but only 1 %2F), when they are dealing with a name with a '/', or a '\'. Will "\x" be undefined when x isn’t \ or /?
>
> Object member name:
> Logically:  Bjørn/Carsten and bar
> In JSON  : "Bjørn/Carsten" and "bar"
>        Or : "Bjørn\/Carsten" and "bar"
>
> JSON pointer:
> Logically:  Bjørn\/Carsten/bar
> In JSON  : "Bjørn\\/Carsten/bar"
>        Or : "Bjørn\\\/Carsten\/bar"
> In IRI   :  Bjørn%2F/Carsten/bar
> ...

Not sure I get the example.

So, the member name is

   Bjørn/Carsten and bar

in JSON, that's

   "Bjørn/Carsten and bar"

no?

In JSON pointer with 0x1f-substution we get (serialized as JSON):

   "/Bjørn\u001fCarsten and bar"

In an IRI, we'd have:

   /Bjørn%1FCarsten%20and%20bar

and, in a URI:

   /Bj%C3%B8rn%1FCarsten%20and%20bar

Best regards, Julian