Subject: | paths method succeeds in search but then fails on path construction |
Date: | Thu, 15 Jun 2017 15:38:58 -0500 |
To: | bug-JSON-Path [...] rt.cpan.org |
From: | James Bowery <jabowery [...] gmail.com> |
This source code:
use JSON::Parse 'parse_json';
use JSON::Path;
local $JSON::Path::Safe = 0;
$json='{"1":{"name":"Name","value":"James
Bowery","id":1,"type":"name","first":"James","middle":"","last":"Bowery"},"2":{"name":"Birthdate","value":"06\/23\/2017","id":2,"type":"date-time","date":"06\/23\/2017","time":"","unix":1498176000},"3":{"name":"Gender","value":"Male","value_raw":"Male","id":3,"type":"radio"},"4":{"name":"Ethnicity","value":"European","value_raw":"European","id":4,"type":"radio"},"5":{"name":"Email","value":"
jabowery@emailservice.com","id":5,"type":"text"}}';
my $json_hash = parse_json($json);
my $p3 = new JSON::Path '$.[?($_->{name} eq "Email")]';
my @paths=$p3->paths($json_hash);
Bombs off while constructing the path it found.
$ perl -d bug.pl
Loading DB routines from perl5db.pl version 1.49
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(bug.pl:3): local $JSON::Path::Safe = 0;
...
DB<3> f
/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm
DB<4> b 421
DB<5> c
JSON::Path::Helper::evalx(/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm:421):
421: my $res = eval $expr;
DB<5> c
JSON::Path::Helper::evalx(/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm:421):
421: my $res = eval $expr;
DB<5> c
JSON::Path::Helper::evalx(/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm:421):
421: my $res = eval $expr;
DB<5> x $v
0 HASH(0x17a7648)
'id' => 5
'name' => 'Email'
'type' => 'text'
'value' => 'jabowery@emailservice.com'
DB<6> x $expr
0 '$v->{name} eq "Email"'
DB<7> n
JSON::Path::Helper::evalx((eval
60)[/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm:421]:1):
1: $v->{name} eq "Email"
DB<7> p $v->{name} eq "Email"
1
DB<8> n
JSON::Path::Helper::evalx(/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm:423):
423: if ($@)
424: {
DB<8>
JSON::Path::Helper::evalx(/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm:428):
428: return $res;
DB<8> p $res
1
DB<9> c
JSON::Path::Helper::evalx(/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm:421):
421: my $res = eval $expr;
...
DB<11> c
JSON::Path::Helper::evalx(/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm:421):
421: my $res = eval $expr;
...
DB<13> c
JSON::Path::Helper::evalx(/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm:421):
421: my $res = eval $expr;
DB<13> x $v
0 'radio'
DB<14> x $expr
0 '$v->{name} eq "Email"'
DB<15> T
@ = DB::DB called from file
'/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm'
line 421
$ = JSON::Path::Helper::evalx(ref(JSON::Path::Helper), '$_->{name} eq
"Email"', 'radio') called from file
'/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm'
line 348
@ = JSON::Path::Helper::_callback_05(ref(JSON::Path::Helper), 'type',
'?($_->{name} eq "Email")', '', ref(HASH), '$;3') called from file
'/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm'
line 369
. = JSON::Path::Helper::walk(ref(JSON::Path::Helper), '?($_->{name} eq
"Email")', '', ref(HASH), '$;3', ref(CODE)) called from file
'/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm'
line 305
. = JSON::Path::Helper::trace(ref(JSON::Path::Helper), '?($_->{name} eq
"Email")', ref(HASH), '$;3') called from file
'/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm'
line 289
@ = JSON::Path::Helper::trace(ref(JSON::Path::Helper), '..;?($_->{name} eq
"Email")', ref(HASH), '$;3') called from file
'/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm'
line 331
@ = JSON::Path::Helper::_callback_04(ref(JSON::Path::Helper), 3, ..,
'?($_->{name} eq "Email")', ref(HASH), '$') called from file
'/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm'
line 369
. = JSON::Path::Helper::walk(ref(JSON::Path::Helper), .., '?($_->{name} eq
"Email")', ref(HASH), '$', ref(CODE)) called from file
'/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm'
line 290
. = JSON::Path::Helper::trace(ref(JSON::Path::Helper), '..;?($_->{name} eq
"Email")', ref(HASH), '$') called from file
'/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm'
line 66
@ = JSON::Path::_get(ref(JSON::Path), ref(HASH), 'PATH') called from file
'/home/jabowery/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/JSON/Path.pm'
line 123
@ = JSON::Path::paths(ref(JSON::Path), ref(HASH)) called from file 'bug.pl'
line 7
Message body is not shown because it is too large.