Re: [apps-discuss] draft-snell-merge-patch-08 in Ruby

"Manger, James H" <James.H.Manger@team.telstra.com> Mon, 20 May 2013 03:26 UTC

Return-Path: <James.H.Manger@team.telstra.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 4B10C21F8F20 for <apps-discuss@ietfa.amsl.com>; Sun, 19 May 2013 20:26:43 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.168
X-Spam-Level:
X-Spam-Status: No, score=-0.168 tagged_above=-999 required=5 tests=[AWL=0.133, BAYES_00=-2.599, HELO_EQ_AU=0.377, HOST_EQ_AU=0.327, J_CHICKENPOX_44=0.6, RELAY_IS_203=0.994]
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 p6fLW1R7fzdc for <apps-discuss@ietfa.amsl.com>; Sun, 19 May 2013 20:26:38 -0700 (PDT)
Received: from ipxbno.tcif.telstra.com.au (ipxbno.tcif.telstra.com.au [203.35.82.204]) by ietfa.amsl.com (Postfix) with ESMTP id 5088021F8F1E for <apps-discuss@ietf.org>; Sun, 19 May 2013 20:26:37 -0700 (PDT)
X-IronPort-AV: E=Sophos;i="4.87,704,1363093200"; d="scan'208";a="129802207"
Received: from unknown (HELO ipcbni.tcif.telstra.com.au) ([10.97.216.204]) by ipobni.tcif.telstra.com.au with ESMTP; 20 May 2013 13:26:37 +1000
X-IronPort-AV: E=McAfee;i="5400,1158,7080"; a="134496971"
Received: from wsmsg3702.srv.dir.telstra.com ([172.49.40.170]) by ipcbni.tcif.telstra.com.au with ESMTP; 20 May 2013 13:26:37 +1000
Received: from WSMSG3153V.srv.dir.telstra.com ([172.49.40.159]) by WSMSG3702.srv.dir.telstra.com ([172.49.40.170]) with mapi; Mon, 20 May 2013 13:26:37 +1000
From: "Manger, James H" <James.H.Manger@team.telstra.com>
To: Steve Klabnik <steve@steveklabnik.com>
Date: Mon, 20 May 2013 13:26:35 +1000
Thread-Topic: [apps-discuss] draft-snell-merge-patch-08 in Ruby
Thread-Index: Ac5U+jC5wL2OOHoLTZS5ZfKURj2hlQACOghg
Message-ID: <255B9BB34FB7D647A506DC292726F6E1151A56E41B@WSMSG3153V.srv.dir.telstra.com>
References: <CABL+ZB6AQGp8WUeH=HZrfm4VCQnmYFQB5vBGP0yghAZUhsjCQg@mail.gmail.com> <255B9BB34FB7D647A506DC292726F6E1151A34C59E@WSMSG3153V.srv.dir.telstra.com> <CABL+ZB6tkggqrdjPFz38j=AXGuueSbANzER24Njm-o3a2S=MZA@mail.gmail.com>
In-Reply-To: <CABL+ZB6tkggqrdjPFz38j=AXGuueSbANzER24Njm-o3a2S=MZA@mail.gmail.com>
Accept-Language: en-US, en-AU
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
acceptlanguage: en-US, en-AU
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
MIME-Version: 1.0
Cc: "apps-discuss@ietf.org" <apps-discuss@ietf.org>
Subject: Re: [apps-discuss] draft-snell-merge-patch-08 in Ruby
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: Mon, 20 May 2013 03:26:43 -0000

> 'null' isn't valid JSON, right? That'd account for your second
> discrepancy.

'null' is a valid JSON value.
JavaScript will happily accept JSON.parse('null').
RFC4627 "JSON" limits application/json content to be an object or array, but my guess is that that will be relaxed to allow any JSON value shortly.


> You can play around with the 1.1 version here, if you don't want to
> bother getting Ruby installed: http://json-merge-patch.herokuapp.com/

Presumably the idea of this site was to return the result of the merge-patch. At the moment it is just echoing the patch.


> https://github.com/steveklabnik/json-merge_patch/blob/master/lib/json/merge_patch.rb

The latest changes to merge_patch.rb don't look right.

Why both removing array elements that are null (obj.compact)? Arrays in merge-patch are effectively primitive (like true, false, number, string). There is no reason for the merge functionality to look inside an array.

A name:null element *in a patch* mean delete the name field in the document. Such a field *in a document*, however, is fine. You shouldn't delete a field from a document that isn't mentioned in the patch -- regardless of whether or not the document field's value is null.


--
James Manger