in reply to Re^2: JSON to HASH
in thread JSON to HASH
If you do:
my $h = from_json( to_json( { a => 1, b => 2, c => [ 1..10 ], d => { ' +a'..'z' } } ) );;
Then to reference key 'a' you need $h->{a};
You can (at a small performance penalty) avoid that by doing:
my %h = %{ from_json( to_json( { a => 1, b => 2, c => [ 1..10 ], d => +{ 'a'..'z' } } ) ) };; print $h{a};; 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: JSON to HASH
by PriNet (Monk) on May 15, 2016 at 06:49 UTC | |
|
Re^4: JSON to HASH
by PriNet (Monk) on May 15, 2016 at 22:34 UTC | |
by AnomalousMonk (Archbishop) on May 15, 2016 at 23:23 UTC | |
by PriNet (Monk) on May 16, 2016 at 00:45 UTC |