laziness, impatience, and hubris | |
PerlMonks |
Re: decoding a JSON objectby kcott (Archbishop) |
on Nov 23, 2022 at 02:52 UTC ( [id://11148314]=note: print w/replies, xml ) | Need Help?? |
G'day anautismobserver, Decode (to a Perl data structure) using JSON. If you also have JSON::XS installed, it will run faster. You can use JSON::XS directly, but some users who maybe can't compile XS code will not be able to run your script. [See Update below] Once you have the JSON data in a Perl format, getting the wanted values is pretty straightforward. See "perldsc - Perl Data Structures Cookbook" if you don't know how to do this. Update: I took "Below is code that returns a JSON object." on face value and, in line with the title, "decoding a JSON object", provided a generic response on how to achieve that. I think you can be forgiven for assuming a method called json() returns JSON; however, that's not the case — see ++1nickt's explanation. — Ken
In Section
Seekers of Perl Wisdom
|
|