2017 © Pedro Peláez
 

library json-merge-patch

Implementation of JSON Merge Patch (https://tools.ietf.org/html/rfc7396).

image

stolt/json-merge-patch

Implementation of JSON Merge Patch (https://tools.ietf.org/html/rfc7396).

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 72 % Grown

The README.md

JSON Merge Patch for PHP

Test Version PHP Version, (*1)

This is an(other) implementation of JSON Merge Patch written in PHP. For a PHP 5.3 compatible version please use the implementation by @clue., (*2)

Installation via Composer

``` bash composer require stolt/json-merge-patch, (*3)


### Usage Now you can use JSON Merge Patch for PHP via the available Composer **autoload file**. ### Apply a patch ```php <?php require_once 'vendor/autoload.php'; use Rs\Json\Merge\Patch; $targetDocument = json_decode('{"title":"Goodbye!","author":{"givenName":"John","familyName":"Doe"},"tags":["example","sample"],"content":"This will be unchanged"}'); $patchDocument = json_decode('{"title":"Hello!","phoneNumber":"+01-123-456-7890","author":{"familyName":null},"tags":["example"]}'); $patchedDocument = (new Patch())->apply( $targetDocument, $patchDocument ); // '{"title":"Hello!","author":{"givenName":"John"},"tags":["example"],"content":"This will be unchanged","phoneNumber":"+01-123-456-7890"}'

Generate a patch document

<?php require_once 'vendor/autoload.php';

use Rs\Json\Merge\Patch;

$sourceDocument = json_decode('{"a":"b","b":"c"}');
$targetDocument = json_decode('{"b":"c"}');

$generatedPatchDocument = (new Patch())->generate(
    $sourceDocument,
    $targetDocument
); // '{"a":null}'

Merge patch documents

<?php require_once 'vendor/autoload.php';

use Rs\Json\Merge\Patch;

$patchDocument1 = json_decode('{"a":"b"}');
$patchDocument2 = json_decode('{"b":"c"}');

$mergedPatchDocument = (new Patch())->merge(
    $patchDocument1,
    $patchDocument2
); // '{"a":"b","b":"c"}'

Running tests

bash composer test, (*4)

License

This library is licensed under the MIT license. Please see LICENSE for more details., (*5)

Changelog

Please see CHANGELOG for more details., (*6)

Contributing

Please see CONTRIBUTING for more details., (*7)

The Versions

29/01 2018

dev-master

9999999-dev https://github.com/raphaelstolt/json-merge-patch

Implementation of JSON Merge Patch (https://tools.ietf.org/html/rfc7396).

  Sources   Download

MIT

The Requires

  • php ^5.4 || ^7.0

 

The Development Requires

json json merge patch json modification

12/08 2016

v1.0.2

1.0.2.0 https://github.com/raphaelstolt/json-merge-patch

Implementation of JSON Merge Patch (https://tools.ietf.org/html/rfc7396)

  Sources   Download

MIT

The Requires

  • php ^5.4 || ^7.0

 

The Development Requires

json json merge patch json modification

25/06 2016

v1.0.1

1.0.1.0 https://github.com/raphaelstolt/json-merge-patch

Implementation of JSON Merge Patch (https://tools.ietf.org/html/rfc7396)

  Sources   Download

MIT

The Requires

  • php ^5.4 || ^7.0

 

The Development Requires

json json merge patch json modification

09/06 2015

v1.0.0

1.0.0.0 https://github.com/raphaelstolt/json-merge-patch

Implementation of JSON Merge Patch (https://tools.ietf.org/html/rfc7386)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

json json merge patch json modification