JSON::Patch - JSON Patch (rfc6902) for perl structures
Version 0.04
use Test::More tests => 2; use JSON::Patch qw(diff patch); my $old = {foo => ['bar']}; my $new = {foo => ['bar', 'baz']}; my $patch = diff($old, $new); is_deeply( $patch, [ {op => 'add', path => '/foo/1', value => 'baz'} ] ); patch($old, $patch); is_deeply($old, $new);
Nothing is exported by default.
Calculate patch for two arguments:
$patch = diff($old, $new);
Convert Struct::Diff diff to JSON Patch when single arg passed:
require Struct::Diff; $patch = diff(Struct::Diff::diff($old, $new));
Apply patch.
patch($target, $patch);
Michael Samoglyadov, <mixas at cpan.org>
<mixas at cpan.org>
Please report any bugs or feature requests to bug-json-patch at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=JSON-Patch. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-json-patch at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc JSON::Patch
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=JSON-Patch
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/JSON-Patch
CPAN Ratings
http://cpanratings.perl.org/d/JSON-Patch
Search CPAN
http://search.cpan.org/dist/JSON-Patch/
rfc6902, Struct::Diff, Struct::Diff::MergePatch
Copyright 2018 Michael Samoglyadov.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install JSON::Patch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JSON::Patch
CPAN shell
perl -MCPAN -e shell install JSON::Patch
For more information on module installation, please visit the detailed CPAN module installation guide.