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

Owner: perl [...]
Requestors: [...]

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

Subject: 0th element of an array not returned
Download (untitled) / with headers
text/plain 734b
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.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to