in reply to Re: Array of hashes?
in thread Array of hashes?

As OP said, it came as JSON, which would have looked exactly like this when received (other than perhaps ordering):

[ { "Lang6" : null, "Lang7" : null, "Lang4" : "ok", "Lang9" : "well" }, { "Lang6" : null, "Lang7" : null, "Lang9" : "two", "Lang4" : "one" } ]

This is one reason why JSON is so great. Translates into Perl data structures very cleanly. In fact, it translates into numerous programming language's data structures very cleanly. Cross-platform and cross-language data awesomeness.

You can stringify it, and send it around, or even store it in a plain text file or database. Not so much with things like Data::Dumper or Storable.

Observe:

use warnings; use strict; use Data::Dumper; use JSON; my $jobj = JSON->new; my $json = '{"a": [1, 2], "b": {"a": 1, "b": 2}}'; print "Look Ma, a string of data!: $json\n\n"; my $perl = $jobj->decode($json); print Dumper $perl; print "\nConvert back from Perl to JSON string, and pretty print:\n"; print $jobj->pretty->encode($perl);

Output:

Look Ma, a string of data!: {"a": [1, 2], "b": {"a": 1, "b": 2}} $VAR1 = { 'a' => [ 1, 2 ], 'b' => { 'a' => 1, 'b' => 2 } }; Convert back from Perl to JSON string, and pretty print: { "a" : [ 1, 2 ], "b" : { "a" : 1, "b" : 2 } }

Now, store it in a DB, send it to a client over the web, or open it up in a program written in Python or C# or whatever and stuff it into its native data structures.