Jmespath;
use strict;
use warnings;
use Jmespath::Parser;
use Jmespath::Visitor;
use JSON qw(encode_json decode_json);
use Try::Tiny;
use v5.14;
our $VERSION = '0.02';
use utf8;
use Encode;
sub compi
$result if not defined $result;
# JSON block result
if ( ( ref ($result) eq 'HASH' ) or
( ref ($result) eq 'ARRAY' ) ) {
try {
$result = JSON->new
->utf8(1)
->al
UOTED} == 0 or
not defined $ENV{JP_UNQUOTED} ) {
$result = q{"} . $result . q{"};
}
return $result;
}
1;
__END__
=head1 NAME
Jmespath - Enabling easy querying for JSON structures.
package Jmespath::Functions;
use strict;
use warnings;
use parent 'Exporter';
use JSON;
use Try::Tiny;
use POSIX qw(ceil floor);
use Jmespath::Expression;
use Jmespath::ValueException;
use Jmespath::J
ueException
->new({ message => 'contains() illegal boolean value' })
->throw
if JSON::is_bool($arg);
Jmespath::ValueException
->new({ message => 'Not a number: [' . $arg .
if JSON::is_bool($subject);
if ( ref $subject eq 'ARRAY' ) {
foreach (@$subject) {
return JSON::true if ( $_ eq $search ); #must be exact string match
}
return JSON::false;
e strict;
use warnings;
use Jmespath::LexerException;
use Jmespath::EmptyExpressionException;
use JSON;
use String::Util qw(trim);
use List::Util qw(any);
use Try::Tiny;
use utf8;
use feature 'unicode
;
$lexeme =~ s/\\`/`/;
my $parsed_json;
try {
$parsed_json = JSON->new->allow_nonref->decode($lexeme);
} catch {
try {
$parsed_json = JSON->new->allow_nonref->decode('"' . trim(
ken_len = $self->{_position} - $start;
return { type => 'literal',
value => $parsed_json,
start => $start,
end => $token_len, };
}
sub _consume_quoted_identifier
warnings;
use Try::Tiny;
use List::Util qw(unpairs);
use Scalar::Util qw(looks_like_number);
use JSON;
use Jmespath::Expression;
use Jmespath::Functions qw(:all);
use Jmespath::AttributeException;
us
eturn $result;
}
=item visit_field(node, value)
Returns the value of a field in the JSON data.
value : the JSON data
node : the AST node being evaluated.
=cut
sub visit_field {
my ($self, $node
not defined $value;
# SHEER NEGATIVE ENERGY HACKERY - FORCE NUMBERS TO BE NUMBERS
# THANK YOU JSON.PM
$value = 1 * $value if $value =~ /^[-][0-9]+$/;
return $value;
}
sub visit_index {
my (
' => sub { ${$_[0]}},
"." => sub { ${$_[0]}},
"eq" => sub { ${$_[0]} },
fallback => sub { ${$_[0]} },
);
sub TO_JSON { return '' . shift; }
1;