Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2018-10-22 12:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...














    Results (119 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!