Feature request: Generate JSON patch from two json string · Issue #42 · raphaelstolt/php-jsonpatch · GitHub
Skip to content

Feature request: Generate JSON patch from two json string #42

Open

Description

@cpxPratik

Is it possible to add feature to generate json string(which contains JSON patch) for two json strings like in below given code, I needed this feature along with applying patch which is already there.

$initial_document =  '{"a":{"b":["c","d","e"]}}';
$updated_document = '{"a":{"b":["c","d","e"],"c":["a","b"],"e":["a"]}}';
$patch_diff = new JsonPatch($initial_document, $updated_document); //
$document_diff = $patch_diff->get_patch();
/* 
$document_diff = '[
        {"op":"add", "path":"/a/d", "value":["a","b"]}, // {"a":{"b":["c","d","e"],"d":["a","b"]}}
        ...
        ...
    ]';
*/

Activity

  1. raphaelstolt commented on Apr 20, 2017

    @raphaelstolt
    Owner

    Not quite sure when I'll find the time to implement this feature. As always with OSS a qualified pull request is welcome.

  2. raphaelstolt commented on Apr 20, 2017

    @raphaelstolt
    Owner

    You might also consider using JSON Merge Patch for PHP for your use case.

  3. joeynovak commented on Nov 30, 2021

    @joeynovak

    I just wanted to +1 this... I know a pull request would be more desirable :). I may have to implement this as the other main package - https://github.com/mikemccabe/json-patch-php is insanely slow when generating patches.

    P.S. Thanks for your awesome work on this package, the code is so clean and well layed out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions