ON
Version 0.6.3
=cut
our $VERSION = "0.6.3";
=head1 DESCRIPTION
Diff, patch, process, query JSON and YAML with ease.
=head1 TOOLS
=over 4
=item B<L<nddiff>>
Human friendly and machine readab
:
Insert Insert value into structure
JsonMergePatch Apply JSON Merge Patch (rfc7396) patches
JsonPatch Apply JSON Patch (rfc6902) patches
Merge Merge str
L<YAML::XS> should be additionally installed for YAML support. L<YAML::XS>
C<0.67> or later and L<JSON::PP> required for correct booleans dump; C<1> for
true and C<0> for false used for earlier L<YAML
ed to lookup path '$path'", 4 if ($@);
for my $r (@refs) {
my $in = s_encode(${$r}, 'JSON', { pretty => 1 });
my ($out, $err);
run3($opts->{command}, \$in, \$out, \$err,
? " (" . join(" ", split("\n", $err)) . ")" : ""), 16;
}
${$r} = s_decode($out, 'JSON');
}
}
1; # End of App::NDTools::NDProc::Module::Pipe
__END__
=head1 NAME
Pipe - pass str
culation toggle. Enabled by default.
=item B<--command|--cmd> E<lt>commandE<gt>
Command to run. JSON encoded structure passed to it's STDIN and it's STDOUT
applied to original structure. Exit 0 expe
use warnings FATAL => 'all';
use parent 'App::NDTools::NDTool';
use Digest::MD5 qw(md5_hex);
use JSON qw();
use Log::Log4Cli;
use App::NDTools::Slurp qw(s_dump);
use Struct::Path 0.80 qw(list_paths p
'bold black',
'strict' => 1, # exit with 8 if unexisted path specified
'ofmt' => 'JSON',
};
}
sub dump {
my ($self, $uri, $data) = @_;
$uri = \*STDOUT unless ($self->{OPT
e {
$self->dump($uri, \@data);
}
}
die_info "All done", 0;
}
my $JSON = JSON->new->canonical->allow_nonref;
sub list_keys {
my ($self, $data) = @_;
my @out;
=> 'all';
use parent qw(Exporter);
use open qw(:std :utf8);
use File::Basename qw(basename);
use JSON qw();
use Scalar::Util qw(readonly);
use App::NDTools::INC;
use App::NDTools::Util qw(is_number)
JSON => {
allow_nonref => 1,
canonical => 1,
pretty => 1,
relaxed => 1,
space_before => 0,
},
);
use constant {
TRUE => JSON::true,
FALSE => JSON
ues/25
# second thing here: get rid of dualvars: YAML::XS load numbers as
# dualvars, but JSON::XS dumps them as strings =(
my @stack = (\$data);
my $ref;
while ($ref = shift @st
AL => 'all';
use parent 'App::NDTools::NDTool';
use Algorithm::Diff qw(compact_diff);
use JSON qw();
use JSON::Patch 0.04 qw();
use App::NDTools::Slurp qw(s_dump);
use App::NDTools::Util qw(is_number
lStyle 0.80 qw(str2path path2str);
use Term::ANSIColor qw(color);
our $VERSION = '0.61';
my $JSON = JSON->new->canonical->allow_nonref;
my %COLOR;
sub arg_opts {
my $self = shift;
return (
tx-text=i' => \$self->{OPTS}->{'ctx-text'},
'grep=s@' => \$self->{OPTS}->{grep},
'json' => sub { $self->{OPTS}->{ofmt} = $_[0] },
'ignore=s@' => \$self->{OPTS}->{ignore},
DTools::NDProc::Module::JsonPatch;
use strict;
use warnings FATAL => 'all';
use parent 'App::NDTools::NDProc::Module';
use App::NDTools::Util qw(chomp_evaled_error);
use JSON::Patch 0.04 qw(patch);
use Log::Log4Cli;
use Struct::Path 0.80 qw(path);
our $VERSION = '0.02';
sub MODINFO { "Apply JSON Patch (rfc6902) patches" }
sub arg_opts {
my $self = shift;
return (
$self->SUPER
d_error($@), 8 if ($@);
}
}
1; # End of App::NDTools::NDProc::Module::JsonPatch
__END__
=head1 NAME
Patch - Apply JSON Patch (rfc6902) patches
=head1 OPTIONS
=over 4
=item B<--[no]blame>
B
== 1) }
@{$rule->{path}};
$rule->{structure} = s_decode($rule->{structure}, 'JSON')
if (exists $rule->{structure});
}
}
sub defaults {
my $self = shift;
});
if (exists $opts->{structure}) {
$opts->{source} = s_encode($opts->{structure}, 'JSON', {pretty => 0});
$source = $opts->{structure}
}
my $spath = eval { str2path($pa
ot defined or empty. Rule-wide option. May be used
several times.
=item B<--structure> E<lt>JSONE<gt>
JSON structure to merge with. Rule-wide option. May be used several times.
=item B<--[no]strict
package App::NDTools::NDProc::Module::JsonMergePatch;
use strict;
use warnings FATAL => 'all';
use parent 'App::NDTools::NDProc::Module';
use Log::Log4Cli;
use Struct::Diff::MergePatch qw(patch);
us
e Struct::Path 0.80 qw(path);
our $VERSION = '0.02';
sub MODINFO { "Apply JSON Merge Patch (rfc7396) patches" }
sub arg_opts {
my $self = shift;
return (
$self->SUPER::arg_opts(),
$_}, $source) } @refs;
}
1; # End of App::NDTools::NDProc::Module::JsonMergePatch
__END__
=head1 NAME
JsonMergePatch - Apply JSON Merge Patch (rfc7396) patches
=head1 OPTIONS
=over 4
=item B<--
$self->{OPTS}->{value} = JSON::true;
} elsif ($_[1] eq '0' or $_[1] =~ /^(F|f)alse$/) {
$self->{OPTS}->{value} = JSON::false;
} else {
$self = shift;
$self->{OPTS}->{value} =
s_decode(delete $self->{OPTS}->{structure}, 'JSON')
if (defined $self->{OPTS}->{structure});
$self->{OPTS}->{value} =
$sel
=item B<--file|-f> E<lt>fileE<gt>
Load inserting value from file.
=item B<--file-fmt> E<lt>RAW|JSON|YAMLE<gt>
Input file format.
=item B<--null|--undef>
Insert null value.
=item B<--number> E<l
return $self->check_args(@{$self->{ARGV}});
}
sub defaults {
return {
'ofmt' => 'JSON',
'pretty' => 1,
'verbose' => $Log::Log4Cli::LEVEL,
};
}
sub dump_opts {