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

From: "Martin Kofahl" <[email-masked]>
Date: Thu, 24 Jan 2013 14:00:52 +0100

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.

Kind regards,
Martin

---

From: Julian Reschke <[email-masked]>
Date: Thu, 24 Jan 2013 15:57:34 +0100

> Maybe you can exert this suggestion.

Essentially you're asking for XPath-like expression (which I sympathize 
with :-).

However, the design goal was to keep things as simple as possible, and 
furthermore the spec just has been approved.

So, too late as well :-)

Best regards, Julian

---

From: Barry Leiba <[email-masked]>
Date: Thu, 24 Jan 2013 10:56:55 -0500

> Essentially you're asking for XPath-like expression (which I sympathize with
> :-).
>

But you could always write up a proposal for an alternative patch
format -- it's perfectly possible to have multiple different patch
formats for different use cases.

Barry

---

From: James M Snell <[email-masked]>
Date: Thu, 24 Jan 2013 08:08:21 -0800

You may want to take a look at my json predicates draft. It provides an
extension for json-patch that addresses a broader range of cases.
 On 2013-01-24 14:00, Martin Kofahl 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
>
>    { "op": "remove", "path": "/features/*/[\"id\"=\"2\"]::**parent" }
> ]
>

So, too late as well :-)

Best regards, Julian
______________________________**_________________
apps-discuss mailing list
[email-masked]
https://www.ietf.org/mailman/**listinfo/apps-discuss<https://www.ietf.org/mailman/listinfo/apps-discuss>

---

From: James M Snell <[email-masked]>
Date: Thu, 24 Jan 2013 08:42:21 -0800

On Thu, Jan 24, 2013 at 5:00 AM, Martin Kofahl <[email-masked]> wrote:

> Hello. I came across the draft-ietf-appsawg-json-patch-10 proposal and
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
> _______________________________________________
> https://www.ietf.org/mailman/listinfo/apps-discuss
>