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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|