Re: [apps-discuss] JSON Patch not suitable for GeoJSON?

James M Snell <jasnell@gmail.com> Thu, 24 January 2013 16:42 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 C4DC621F8503 for <apps-discuss@ietfa.amsl.com>; Thu, 24 Jan 2013 08:42:43 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.766
X-Spam-Level:
X-Spam-Status: No, score=-1.766 tagged_above=-999 required=5 tests=[AWL=0.833, BAYES_00=-2.599, HTML_MESSAGE=0.001, NO_RELAYS=-0.001]
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 8yibZQm0VIY4 for <apps-discuss@ietfa.amsl.com>; Thu, 24 Jan 2013 08:42:42 -0800 (PST)
Received: from mail-ia0-x22c.google.com (ia-in-x022c.1e100.net [IPv6:2607:f8b0:4001:c02::22c]) by ietfa.amsl.com (Postfix) with ESMTP id 8602B21F84F3 for <apps-discuss@ietf.org>; Thu, 24 Jan 2013 08:42:41 -0800 (PST)
Received: by mail-ia0-f172.google.com with SMTP id u8so5147584iag.31 for <apps-discuss@ietf.org>; Thu, 24 Jan 2013 08:42:41 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=2yaV1r2PCdk08Tf0d9sKcbHR27FmN2hmioVw8EwH+bc=; b=xxtZMHQADD7ZZg4/nOPcx7iPIirRRF1b2Z68ReNFdfVLl3/1A5XWE2w+sT0VBpzYmr f0pkxtK6CX6RGZGV6v7iZ75alrSw/KHanfq0sHAHQGXDVeqBo3tQIm5c7KIVEoaKYsC2 rTwrO7QigIrGR5S0Mcm4SNDPH6eS+SxmrLYZR1R9YMcFb3wjI8uFHVzGCHc6rWL6pzMo 8R4dwX3aQ4LnBl2DBc9wDpzOJZtkxTULvp4XMg01MDh1DF1HohByjwCbNd7pImZBAdiF XIrYn/a2VS7HGsSfZVdbrQaG1R8IN/isy5tHtWX41isDNldsMTjcaibVE1zn+aoGcqMw Nzxw==
X-Received: by 10.42.58.202 with SMTP id j10mr1517760ich.39.1359045761088; Thu, 24 Jan 2013 08:42:41 -0800 (PST)
MIME-Version: 1.0
Received: by 10.64.26.137 with HTTP; Thu, 24 Jan 2013 08:42:21 -0800 (PST)
In-Reply-To: <20130124130052.272540@gmx.net>
References: <20130124130052.272540@gmx.net>
From: James M Snell <jasnell@gmail.com>
Date: Thu, 24 Jan 2013 08:42:21 -0800
Message-ID: <CABP7RbcOH_-EQJczWDTVKjYnyJah4uJtPCn2cRCcSegEa9hVvg@mail.gmail.com>
To: Martin Kofahl <M.Kofahl@gmx.de>
Content-Type: multipart/alternative; boundary="20cf30334613d2bc6904d40b7f55"
Cc: IETF Apps Discuss <apps-discuss@ietf.org>
Subject: Re: [apps-discuss] JSON Patch not suitable for GeoJSON?
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, 24 Jan 2013 16:42:43 -0000

On Thu, Jan 24, 2013 at 5:00 AM, Martin Kofahl <M.Kofahl@gmx.de> wrote:

> Hello. I came across the draft-ietf-appsawg-json-patch-10 proposal and
> hope that's the right here place to put a question.
>
> As far I can see any remove, replace, etc. operations can be applied on
> object members or numbered array elements, only. I don't think this is
> sufficient for some formats. Taking GeoJSON
>
> { "type": "FeatureCollection",
>   "features": [
>     { "type": "Feature",
>       "id": "2",
>       "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
>       "properties": {"prop0": "value0"}
>     },
>     ...
>   ]
> }
>
> as an example, operations may have to be applied on objects filtered by
> some key-value-conditions in its leafs.
>
> A JSON Patch document may have to look like this:
>
> [
>   { "op": "remove", "path": "/features/*/[\"id\"=\"2\"]::parent" }
> ]
>
> Maybe you can exert this suggestion.
>
>
Take a look at
http://tools.ietf.org/html/draft-snell-json-test-05#section-2.5.1

[
  {
    "op": "remove",
    "path": "/features/0",
    "if": {
      "op": "test",
      "path": "/features/0/id",
      "value": "2"
    }
]

Yes, I know it's not quite the same as your example but it's closer. I
could get it closer by defining an iterator operation... e.g.

[
  {
    "op": "each",
    "path": "/features",
    "apply": {
      "op": "remove",
      "if": {
        "op": "test",
        "path": "/id",
        "value": "2"
      }
    }
  }
]

The way to interpret this would be: For each member of /features (whether
it's an array or object), set the member as the context object and apply
the remove operation only if the condition holds for that item.

Alternatively, we can use the json-predicates draft as the base to
introduce a more complete pointer expression syntax... e.g.

[
  { "op": "remove", "exp": "/features/*/[\"id\"=\"2\"]::parent" }
]

Note the use of "exp" instead of "path"... the hope with json-pointer is to
coexist with json-patch, not replace it...

- James


> Kind regards,
> Martin
> _______________________________________________
> apps-discuss mailing list
> apps-discuss@ietf.org
> https://www.ietf.org/mailman/listinfo/apps-discuss
>