in reply to Enumerate variable JSON key names/Values
I think you are just asking for this:
#!/usr/bin/env perl use strict; use warnings; my $json = [ { 'readings' => [ { 'asddad' => '123', 'fsfsf' => 'abc', 'sdfsdfsfsf' => 'x1y', } ], 'FWTYPE' => 'XXX', 'FWID' => '123' } ]; # Keys and values my $hashref = $json->[0]{readings}[0]; for my $k (keys %$hashref) { print "Key '$k' has value '$hashref->{$k}'\n"; } # Just keys my @k = keys %$hashref; print "All keys: @k\n";
See also perldsc for more on these sorts of nested data structures.
🦛
|
|---|