-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: composer.json
- Loading branch information
Showing
17 changed files
with
454 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
vendor/ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,45 @@ | ||
jsonpatch | ||
========= | ||
|
||
Implementation of JSON Patch (http://tools.ietf.org/html/rfc6902) in PHP using JSON Pointer from: | ||
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/dee95637-0141-4caa-b6bf-1189a848128c/big.png)](https://insight.sensiolabs.com/projects/dee95637-0141-4caa-b6bf-1189a848128c) | ||
|
||
https://github.com/webnium/php-json-pointer | ||
Implementation of JSON Patch (http://tools.ietf.org/html/rfc6902) in PHP | ||
|
||
Currently still developing, in the next couple of days I will post documentation and some refactors. | ||
Installation | ||
------------- | ||
Require [`victuxbb/jsonpatch`](https://packagist.org/packages/victuxbb/jsonpatch) | ||
into your `composer.json` file: | ||
|
||
Example of test.php | ||
``` json | ||
{ | ||
"require": { | ||
"victuxbb/jsonpatch": "@stable" | ||
} | ||
} | ||
``` | ||
|
||
<?php | ||
Documentation | ||
------------- | ||
``` php | ||
|
||
require 'vendor/autoload.php'; | ||
use victuxbb\JsonPatch\Patcher; | ||
$targetJSON ='{"baz": "qux","foo": "bar"}'; | ||
$patchOperations = '[ | ||
{ "op": "replace", "path": "/baz", "value": "boo" } | ||
]'; | ||
$expected ='{"baz":"boo","foo":"bar"}'; | ||
|
||
$patcher = new Patcher(); | ||
$result = $patcher->patch($targetJSON,$patchOperations); | ||
|
||
$targetJSON ='{"a":{"b":["c","d","e"]}}'; | ||
``` | ||
|
||
$patchDocument = '[ | ||
{"op":"add", "path":"/a/d", "value":["a","b"]}, | ||
{"op":"move", "path":"/a/c", "from":"/a/d"}, | ||
{"op":"copy", "path":"/a/e", "from":"/a/c"}, | ||
{"op":"replace", "path":"/a/e", "value":["a"]} | ||
]'; | ||
Thanks to | ||
--------- | ||
|
||
$result = $patcher->patch($targetJSON,$patchDocument); | ||
*https://github.com/webnium | ||
|
||
print_r($result); | ||
*https://github.com/javadegava | ||
|
||
Thanks to: | ||
*http://williamdurand.fr/2014/02/14/please-do-not-patch-like-an-idiot/ | ||
|
||
https://github.com/webnium | ||
https://github.com/javadegava | ||
http://williamdurand.fr/2014/02/14/please-do-not-patch-like-an-idiot/ | ||
http://www.groupalia.com/ | ||
*http://www.groupalia.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
/** | ||
* This file is part of webnium/json-pointer. | ||
*/ | ||
|
||
namespace victuxbb\JsonPatch\Exception; | ||
|
||
/** | ||
* Interface for Exception | ||
*/ | ||
interface ExceptionInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* This file is part of webnium/json-pointer. | ||
*/ | ||
|
||
namespace victuxbb\JsonPatch\Exception; | ||
|
||
/** | ||
* None existent value exception. | ||
* | ||
* This exception will be thrown when a pointer references none existent value. | ||
*/ | ||
class NoneExistentValue extends \RuntimeException implements ExceptionInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* This file is part of webnium/json-pointer. | ||
*/ | ||
|
||
namespace victuxbb\JsonPatch\Exception; | ||
|
||
/** | ||
* SyntaxError exception. | ||
* | ||
* This Exception will be thrown when a JSON Pointer has syntax error. | ||
*/ | ||
class SyntaxError extends \RuntimeException implements ExceptionInterface | ||
{ | ||
} |
Oops, something went wrong.