Re: [apps-discuss] Last Call: <draft-ietf-appsawg-json-patch-08.txt> (JSON Patch) to Proposed Standard

James M Snell <jasnell@gmail.com> Tue, 11 December 2012 17:22 UTC

Return-Path: <jasnell@gmail.com>
X-Original-To: ietf@ietfa.amsl.com
Delivered-To: ietf@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 82B5A21F84CD; Tue, 11 Dec 2012 09:22:44 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.834
X-Spam-Level:
X-Spam-Status: No, score=-3.834 tagged_above=-999 required=5 tests=[AWL=-0.236, BAYES_00=-2.599, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-1]
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 eP35wJcQMseR; Tue, 11 Dec 2012 09:22:43 -0800 (PST)
Received: from mail-ie0-f175.google.com (mail-ie0-f175.google.com [209.85.223.175]) by ietfa.amsl.com (Postfix) with ESMTP id 7D42B21F84CA; Tue, 11 Dec 2012 09:22:38 -0800 (PST)
Received: by mail-ie0-f175.google.com with SMTP id qd14so12938194ieb.6 for <multiple recipients>; Tue, 11 Dec 2012 09:22:38 -0800 (PST)
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=55steGPZ4XVOvlwQHjlGVsQWc408AgC8tnGDfyBdyf0=; b=Lc8bBBS8eV/p/FKdzm5MzLpTmwz41P+v6RQhufw0Am0cO/c/7y5l/8zM4tYojP/9wZ SVMajKW14I2TX7jvmZ2cRA2EDBJMXkiZRlIDqqbkkDdGgxt1eNxUEhwecCPGUt0H/5Gn rKvoohb1mJz0/Kj5eCf5NueVZlkz3fXsY4RDA/wYpy1d3E8Y/Te2+Uk7zlnfDhgQ9Lmt 0sEEN3ZajFRdxPb7ekucQltYBSEIxPBmxarwHzcx4EG2IFQQY9IgydDyOSV0fe5xKt+d pLNL0ZGAQAHLcQRunCb87mpDceQr/SR055qGMscG0ahyc07h9KPeJEHwUh6orgdNhpdg PKIQ==
Received: by 10.50.151.165 with SMTP id ur5mr3032978igb.24.1355246554595; Tue, 11 Dec 2012 09:22:34 -0800 (PST)
MIME-Version: 1.0
Received: by 10.64.7.19 with HTTP; Tue, 11 Dec 2012 09:22:14 -0800 (PST)
In-Reply-To: <CAC4RtVBNxQu03hZxFZiRg-7s2G_KYKFJjUUvSC_UUFwE_FZFdg@mail.gmail.com>
References: <20121211150005.28209.96763.idtracker@ietfa.amsl.com> <CAC4RtVBNxQu03hZxFZiRg-7s2G_KYKFJjUUvSC_UUFwE_FZFdg@mail.gmail.com>
From: James M Snell <jasnell@gmail.com>
Date: Tue, 11 Dec 2012 09:22:14 -0800
Message-ID: <CABP7RbfnfMxEUna=snZHHhFkgorxCM+uTXL69RMriyLo-A6qig@mail.gmail.com>
Subject: Re: [apps-discuss] Last Call: <draft-ietf-appsawg-json-patch-08.txt> (JSON Patch) to Proposed Standard
To: Barry Leiba <barryleiba@computer.org>
Content-Type: multipart/alternative; boundary="e89a8f23541d78414c04d096ed35"
X-Mailman-Approved-At: Wed, 12 Dec 2012 10:26:48 -0800
Cc: IETF discussion list <ietf@ietf.org>, "apps-discuss@ietf.org" <apps-discuss@ietf.org>
X-BeenThere: ietf@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: IETF-Discussion <ietf.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/ietf>, <mailto:ietf-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/ietf>
List-Post: <mailto:ietf@ietf.org>
List-Help: <mailto:ietf-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/ietf>, <mailto:ietf-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 11 Dec 2012 17:22:45 -0000

You are reading it correctly. Note also that the very next bullet point
says:

  A member to add to an existing object - whereupon the supplied
  value is added to that object at the indicated location.  If the
  member already exists, it is replaced by the specified value.

So an "add" is really a "replace" that does not have the "target location
MUST exist" restriction. Personally, I'm not too fond of that decision. For
anything other than an array, "add" should fail if the target already
exists. For arrays, "add" should insert but never replace an existing
value.

- James


On Tue, Dec 11, 2012 at 7:25 AM, Barry Leiba <barryleiba@computer.org>wrote:

> > Abstract
> >    JSON Patch defines the media type "application/json-patch", a JSON
> >    document structure for expressing a sequence of operations to apply
> >    to a JSON document, suitable for use with the HTTP PATCH method.
> ...
> > http://datatracker.ietf.org/doc/draft-ietf-appsawg-json-patch/
>
> I've reviewed JSON Patch and JSON Pointer as responsible AD, and am
> very happy with the documents -- this is good work, well written.  I
> came up with one issue that I want to discuss as part of last call:
>
>    4.1.  add
>
>    The "add" operation adds a new value at the target location.  The
>    operation object MUST contain a "value" member that specifies the
>    value to be added.
>
>    For example:
>
>    { "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] }
>
>    When the operation is applied, the target location MUST reference one
>    of:
>
>    o  The root of the target document - whereupon the specified value
>       becomes the entire content of the target document.
>
> Now, what this means is that if we start with this:
>
> { "a": { "num": 1 } }
>
> and we apply this:
>
> { "op": "add", "path": "", "value": [ "foo", "bar" ] }
>
> we end up with this:
>
> [ "foo", "bar" ]
>
> This doesn't strike me as having any sense of an "add" operation -- it
> appears to be a special case that doesn't fit.  In any other
> situation, using any other path, the operation either adds something
> to what's already there, or it fails.  But when the path is "", it's
> anomalous.
>
> So, three questions:
>
> 1. Do I have this right, or am I mistaken about the result of that
> operation?
>
> 2. Assuming I have it right, can someone explain why it's this way?
>
> 3. Can someone explain why this is the right way to specify it, rather
> than using "replace" for this?
>
> Barry
> _______________________________________________
> apps-discuss mailing list
> apps-discuss@ietf.org
> https://www.ietf.org/mailman/listinfo/apps-discuss
>