Dear Perl lazyweb: how to construct read-only data objects out of JSON?
I recently updated a client called WebService::Geocodio for the Geocod.io geocoding service. Traditionally, geocoding means turning a mailing address into latitude/longitude coordinates (or the reverse operation, turning latitude/longitude into a mailing address.)
In a recent update of the upstream service they included the ability to fetch additional data fields including timezone, congressional district, school district and so forth. Is there a good CPAN module (or a recommendation) to take a Perl data structure like a hash and turn it into a Moo(::Lax) object "automagically?" I had a look but I didn't find anything especially suitable.
These data structures are purely informational in nature and just have getters for their attribute names. This would be less difficult to accomplish using Moose (obviously) but I'm wondering if there are any suggestions for something that installs getters for hash keys dynamically and is Moo-friendly.
Thanks!
Here's a quick solution using Class::Tiny. It's not much more difficult with Moo.
http://gist.github.com/10198397
how about
MooseX::Blessed::Reconstruct
https://metacpan.org/release/MooseX-Blessed-Reconstruct