I can't go into a lot of detail at the moment, but if you're open to using something non-Moose based (at least for inflating the nested data structures), Venus can do all of this for you via the "Venus::Role::Coerciable" role. If you want to stick with Moose you could try reverse engineering "Venus::Role::Coerciable" and using it with your Moose classes. Here's how to do it in Venus:
package JsonData;
use Venus::Class;
with 'Venus::Role::Coercible';
attr 'icon';
attr 'url';
attr 'datetime';
attr 'subject_html';
sub coerce {
{
...,
icon => 'JsonData/Icon',
url => 'Mojo/URL',
datetime => 'Mojo/Date',
subject_html => 'Mojo/DOM',
...,
}
}
package JsonData::Icon;
use Venus::Class;
with 'Venus::Role::Coercible';
attr 'url';
attr 'comment';
attr 'picid';
attr 'keywords';
sub coerce {
{
...,
url => 'Mojo/URL',
...,
}
}
1;
Venus::Class
Venus::Role::Coercible
"I am inevitable." - Thanos