[apps-discuss] draft-pbryan-json-patch-04 - comments

Vadim Zaliva <krokodil@gmail.com> Thu, 08 March 2012 21:46 UTC

Return-Path: <krokodil@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 2C52521F86AA for <apps-discuss@ietfa.amsl.com>; Thu, 8 Mar 2012 13:46:13 -0800 (PST)
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 RbpoaQxoJ26E for <apps-discuss@ietfa.amsl.com>; Thu, 8 Mar 2012 13:46:12 -0800 (PST)
Received: from mail-yx0-f172.google.com (mail-yx0-f172.google.com [209.85.213.172]) by ietfa.amsl.com (Postfix) with ESMTP id 914A421F854E for <apps-discuss@ietf.org>; Thu, 8 Mar 2012 13:46:12 -0800 (PST)
Received: by yenm5 with SMTP id m5so625522yen.31 for <apps-discuss@ietf.org>; Thu, 08 Mar 2012 13:46:12 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version:x-mailer; bh=h9ezvzla1QDBvWiqpP/A/5b3NXk9/QAARuP3wFllGNU=; b=pgLWGZIUvvwVy3RfHX8unv4NnOdtqEB3bynJrfxAh+s50+Mw0wCa5vZ8RW54wiev7x wapMZ+ewrsT/qJCXTrGyAqY6TqLZs/PimmteoVmTwt8t8ayPoqnBY4RavXMZjaG9pHFm 29UV96dtIH8AaYXN6LXOCVeedjujGFu4q1W5QX76KWDxmoByVByqOacN2lqS+Ld+hCDt NMtX7oQ+GL3O9bG9dCi+p+faSoWGFT8t7oqnutSmeMUMAWOl2H2AhC++2hRjCMaGyRW1 ZZc9MiPt7GaIJHiEcXBf0DEum3ydsdgGp2HB/DoV/OMQvX7GlD1OIcMz4JEK+ucd4NTy TN3Q==
Received: by 10.50.195.131 with SMTP id ie3mr9158362igc.52.1331243172031; Thu, 08 Mar 2012 13:46:12 -0800 (PST)
Received: from [10.0.1.2] (173-8-183-154-SFBA.hfc.comcastbusiness.net. [173.8.183.154]) by mx.google.com with ESMTPS id df2sm15343776igb.10.2012.03.08.13.46.10 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 08 Mar 2012 13:46:11 -0800 (PST)
From: Vadim Zaliva <krokodil@gmail.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Date: Thu, 08 Mar 2012 13:46:08 -0800
Message-Id: <9F0A2492-AE7D-4C12-8BB0-13489FD7F6C1@gmail.com>
To: apps-discuss@ietf.org
Mime-Version: 1.0 (Apple Message framework v1257)
X-Mailer: Apple Mail (2.1257)
Subject: [apps-discuss] draft-pbryan-json-patch-04 - comments
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, 08 Mar 2012 21:48:54 -0000

Hi!

I was looking for JSON patch formats available and found this draft. It looks nice - concise and to the point. I would like to share few comments I have.

1. I am not sure if 'test' operation should be part of it. The purpose of the patch is to modify the document. 'test' operation either succeeds of fails, but it is unclear how this information will be communicated or used. It almost looks like a API operation rather than patch format instruction. I would argue that in current state it should not be included in the format. 

I could see a case when it could be included as a part of conditional syntax. In this case 'test' becomes a container for other operations which would be executed only if the test succeeds. For example:


{ "test": "/baz", "value": "qux",
	"onsuccess" : [
	 	{ "replace": "/baz", "value": "boo" },
	 	{ "add": "/baz1", "value": "qux" }
	]
}

2. In most examples "value" property holds simple scalar values (strings or integers) or arrays of such. I think it should be possible to use arbitrary complex JSON data structures as such values. I hope this was the intention. Perhaps adding an example with more complex value (object or array) could illustrate this very powerful capability. For example A.1 could be modified as following;

An example target JSON document:

   {
       "foo": "bar"
   }

   A JSON Patch document:

   [
       { "add": "/baz", "value": {"a":1,"b":2} }
   ]

   The resulting JSON document:

   {
       "baz": {"a":1,"b":2},
       "foo": "bar"
   }

Sincerely,
Vadim