Subject: [apps-discuss] JSON Predicates Draft (for JSON Patch)

From: James M Snell <[email-masked]>
Date: Mon, 1 Oct 2012 15:54:40 -0700

Now that the updated JSON Patch draft has been published [2] ... here is
the first draft of the JSON Predicates doc [1]

[1] http://www.ietf.org/id/draft-snell-json-test-00.txt
[2] http://tools.ietf.org/html/draft-ietf-appsawg-json-patch-05

Example JSON-Patch with Predicates:

  # Adds a value only if path "/a/b/c"
  # is undefined or consists of three
  # numeric digits ...

  [
    {
      "op": "or",
      "path": "/a/b",
      "apply": [
        {
          "op": "undefined",
          "path": "/c"
        },
        {
          "op": "matches",
          "path": "/c",
          "value": "^\\d{3}$"
        }
      ]
    },
    {
      "op": "add",
      "path": "/a/b/d",
      "value": 123
    }
  ]

As always, comments are more than welcome.

- James