Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Need something like a SQL query for JSON data structures (JSON::XS)

by Laurent_R (Canon)
on Sep 06, 2013 at 06:17 UTC ( #1052654=note: print w/replies, xml ) Need Help??


in reply to Re^2: Need something like a SQL query for JSON data structures (JSON::XS)
in thread Need something like a SQL query for JSON data structures (JSON::XS)

With a simple hash, to grep the keys:

my @results = grep /taco/, keys %hash;

To grep the values:

my @results = grep /taco/, values %hash;

To get the keys whose values match a regex:

my @results = map {$hash{$_} =~ /taco/ ? $_:  ()} keys %hash;

Replies are listed 'Best First'.
Re^4: Need something like a SQL query for JSON data structures (JSON::XS)
by walkingthecow (Friar) on Sep 06, 2013 at 06:25 UTC
    json_decode in my context returns an array of hash references. I posted the method that worked for me, though there may be an easier/better way to do it.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1052654]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2018-05-27 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?