Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cpxPratik opened this issue Apr 20, 2017 · 3 comments
Open

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

cpxPratik opened this issue Apr 20, 2017 · 3 comments

Comments

@cpxPratik
Copy link

cpxPratik commented Apr 20, 2017

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"]}}
        ...
        ...
    ]';
*/
@raphaelstolt
Copy link
Owner

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

@raphaelstolt
Copy link
Owner

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

@raphaelstolt raphaelstolt mentioned this issue Nov 16, 2017
@joeynovak
Copy link

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
Projects
None yet
Development

No branches or pull requests

3 participants