in reply to How to properly check a JSONPath for existance?

kroach gave the right answer but since it's Perl, partly :P, and since I'd never heard of JSON::Path before this, I want to show the way I would have approached it before learning there was a more native tool (from our own tobyink); with Data::Diver (update to correct oversight: from our own tye) and JSON.

use strictures; use JSON; use Data::Diver "Dive"; my $json = <<''; { "key" : "value" ,"object" : { "elem1": "value1", "elem2": "value2" } ,"array" : [ 0, 1 ] ,"not_defined" : null } my $data = decode_json $json; for my $key (qw/ key object non_exist array not_defined /) { my @exists = Dive( $data, $key ); printf "%20s -> %s\n", $key, @exists ? "yeppers" : "nopers"; } __END__ key -> yeppers object -> yeppers non_exist -> nopers array -> yeppers not_defined -> yeppers