mikemccabe / json-patch-php

PHP implementation of JSON-patch (IETF RFC 6902)
112 stars 27 forks source link

Upgrade to support Draft 10 syntax #2

Closed warpech closed 10 years ago

warpech commented 11 years ago

Thanks for a great library!

I made a few changes that make 100% tests from https://github.com/mikemccabe/json-patch-tests (master) passing.

Works for me so may work for others as well.

mikemccabe commented 11 years ago

Thank you! I'll try to review it soon. Have you checked it against https://github.com/json-patch/json-patch-tests ?

warpech commented 11 years ago

Sorry, I only tested against https://github.com/mikemccabe/json-patch-tests. I didn't realize that the other repo is now the leading one.

I made my changes because I needed as PHP counterpart to the JavaScript implementation I contributed to (Starcounter-Jack/JSON-Patch)

bendiy commented 11 years ago

I merged this Pull Request into #3 and ran the tests against https://github.com/json-patch/json-patch-tests. Works fine.

bendiy commented 11 years ago
JsonPatch::diff($doc1, $doc2);

@warpech This is still returning Draft 2 style patches after merging in your changes:

[
  {
    "add":"\/comments\/0",
    "value":{
      "text":"test",
      "created":"2013-06-14T18:50:21.904Z",
    }
  }
]

I'll update diff() to the final RFC style next week.

It should look like:

[
  {
    "op":"add",
    "path":"\/comments\/0",
    "value":{
      "text":"test",
      "created":"2013-06-14T18:50:21.904Z",
    }
  }
]

This does seem to work fine when applying final RFC style patches:

JsonPatch::patch($doc1, $patch);
bendiy commented 11 years ago

diff() is now working as expected. See #3