in reply to Array of hashes?

I thought it was an array of hashes, but apparently, it is not.

It looks like the output from Data::Dumper to me.

We would need more information about where is came from or what you are trying to do with it to be able to help further.

Replies are listed 'Best First'.
Re^2: Array of hashes?
by stevieb (Canon) on Jan 04, 2021 at 17:43 UTC

    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.