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:
- The input string requires some cleanup, as shown.
- 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,