use JSON::Path; $json = q( { "array": [ 1, 2, 3], "string": "string_value", "object": { "obj1": "val1", "obj2": "val2" } } ); $arr_path = JSON::Path->new( q($.array) ); $scal_path = JSON::Path->new( q($.string) ); $value = $arr_path->value(); if ( ! ( defined ref $value ) ) { print "SCALAR\n" } elsif ( ref $value eq q(ARRAY) ) { print "ARRAY\n" } else { print "NEITHER" } #### Use of uninitialized value $json_object in concatenation (.) or string at /usr/local/share/perl/5.20.2/JSON/Path/Evaluator.pm line 84. Unable to decode as JSON: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "(end of string)") at /usr/local/share/perl/5.20.2/JSON/Path/Evaluator.pm line 81. at /usr/local/share/perl/5.20.2/JSON/Path/Evaluator.pm line 79.