Parsing JSON string with Perl when the elements name are unknown

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • liadmz
    New Member
    • Jul 2009
    • 32

    Parsing JSON string with Perl when the elements name are unknown

    Hi,

    I would like to parse JSON string using perl.
    which is very trivial up until the moment the elements name are unknown.

    normally I would use:
    Code:
    my @elem= @{ $decoded->{'elements'} };
    foreach my $el ( @elem) {
      print $el->{"attr"} . "\n";
    }
    How can I do the same assuming I have no knowledge on the elements names (I'm sure there has to be a way to access it using the index, I just could not find it)

    THANKS!
Working...