Skip to content

JSON::PATH values() function fails if JSON key has a colon in it #55

Description

@kleiner008

Hi,

Using JSON::Path 1.0.6 on EL9 with perl 5.32

It appears that if you do something like the following:

use strict;
use warnings;
use JSON;
use JSON::Path;
use Data::Dumper;

my $json_string='{"key1": [{":key2:test": { "parameters": "desired_value" } } ] }';
my $data_ref = decode_json($json_string);
my $jpath_string = "\$['key1'][0][':key2:test']";
my $jpath = JSON::Path->new($jpath_string);
my @values = $jpath->values($data_ref);
print Dumper @values;

Results in the following error:

Argument "key2" isn't numeric in numeric eq (==) at …/perl/5.032/lib/perl5/JSON/Path/Evaluator.pm line 406.
Argument "test" isn't numeric in numeric lt (<) at …/perl/5.032/lib/perl5/JSON/Path/Evaluator.pm line 409.

It appears the _slice is being called when it shouldn't be.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions