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:
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|