JSON::MergePatch - JSON Merge Patch implementation
use JSON::MergePatch; use Test::More; my $target_json = '{"a":"b"}'; my $patch = +{ 'a' => 'c' }; my $result_json = json_merge_patch($target_json, $patch); my $diff = json_merge_diff($result_json, $target_json); is $result_json, '{"a":"c"}'; is_deeply $diff, $patch; done_testing;
JSON::MergePatch is JSON Merge Patch implementation for Perl.
This method merges patch into the target JSON.
my $result_json = JSON::MergePatch->patch('{"a":"b"}', { 'a' => 'c' }); # $result_json = '{"a":"c"}';
This method outputs diff between JSON.
my $diff = JSON::MergePatch->diff('{"a":"c"}', '{"a":"b"}'); # $diff = { 'a' => 'c' };
Same as patch() method.
patch()
Same as diff() method.
diff()
Copyright (C) Taishi Hiraga.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Taishi Hiraga <sojiro@cpan.org>
To install JSON::MergePatch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JSON::MergePatch
CPAN shell
perl -MCPAN -e shell install JSON::MergePatch
For more information on module installation, please visit the detailed CPAN module installation guide.