in reply to Getting Value from specific key from json data dump

Hello bizactuator,

Here is a proof-of-concept using the JSON module from CPAN:

use strict; use warnings; use JSON; my $string = read_json(); my $hashref = decode_json($string); for my $item (@{ $hashref->{items} }) { if (exists $item->{orderItemTitle}) { printf "Order Item Title: %s\n", $item->{orderItemTitle}; } } sub read_json { my $string =<<'EOS'; {\"order\\\\.shipTo\\\\.country\":\"US\",\"euddAccepted\":false,\"isFr +eeCart\":false,\"discount\ ... < most of input string omitted here > ... \"hasAnyDelayedDeliveryItems\":false,\"addOnSubtotal\":\"$0.00\",\"sto +ry\":\"FCF6F91A\"} EOS $string =~ s{ \\" }{"}gx; return $string; }

Output:

14:22 >perl 2006_SoPW.pl Order Item Title: Freelance Profit Academy 14:22 >

Notes:

  1. The input string requires some cleanup, as shown.
  2. To find the structure of the decoded JSON hash reference, dump it using a module such as Data::Dumper or Data::Dump. (Deciphering the output is the tricky part!)

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,