Skip Menu |

This queue is for tickets about the JSON-Path CPAN distribution.

Report information
The Basics
Id: 66232
Status: resolved
Priority: 0/
Queue: JSON-Path

People
Owner: perl [...] toby.ink
Requestors: mutant.nz [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.100
  • 0.080_01
Fixed in: 0.101



Subject: 0th element of an array not returned
If you have a path addressing the 0th element of an array, the whole array is returned. e.g. if you do: my $data = { 'foo' => [ { 'bar' => 1, }, { 'bar' => 2, }, { 'bar' => 3, }, ] }; my $jpath1 = JSON::Path->new('$.foo[0]'); my @values = $jpath1->values($data); @values will then contain all the array elements, instead of the first (i.e. the 0th). I think the fix is to change the second line of the trace sub to: return $self->store($path, $val) if $expr eq ''; The problem is $expr is 0 when trying to find the 0th element, so the expression currently returns true, when it still has further to walk down the structure.
Resolved in 0.101, and new test case added.