MooseX::Role::JSONObject::Util - helper functions for MooseX::Role::JSONObject
The MooseX::Role::JSONObject::Util module provides several utility functions for the MooseX::Role::JSONObject role.
MooseX::Role::JSONObject::Util
MooseX::Role::JSONObject
Please note that these functions are only meant for internal use by MooseX::Role::JSONObject and, as such, any and all of them may change without prior notice.
identify_type()
Examine a Moose::Meta::Attribute object and return a list of strings describing recursively the attribute's type, e.g. ['maybe', 'hash', 'num'] for a Maybe[HashRef[Int]] attribute or ['hash', 'array', 'obj', 'Some::Class'] for a HashRef[ArrayRef[Some::Class]] attribute.
Moose::Meta::Attribute
['maybe', 'hash', 'num']
Maybe[HashRef[Int]]
['hash', 'array', 'obj', 'Some::Class']
HashRef[ArrayRef[Some::Class]]
Note that all types descending from Num are represented as 'num'.
Num
'num'
get_value()
Given an attribute and a function to recurse into objects, parse the attribute's type using identify_type() and process the given type's value appropriately. This function is used by both the meta_to_json() and meta_from_json() functions (see below) with different functions passed as $objfunc.
meta_to_json()
meta_from_json()
$objfunc
get_value_type()
Do the actual work of get_value() after the attribute's type has been examined by identify_type().
Build a Perl hash suitable for a JSON representation of an object (or a value) of the given Moose::Meta::Class type. Uses get_value(), passing a reference to itself as the function to process complex objects.
Moose::Meta::Class
Build a Moose object (or a simple type's value) of the given Moose::Meta::Class type, initializing it and its attributes recursively with the values supplied in the given Perl hash. Uses get_value(), passing a reference to itself as the function to process complex objects.
Copyright (C) 2015 Peter Pentchev <roam@ringlet.net>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Peter Pentchev <roam@ringlet.net>
To install MooseX::Role::JSONObject, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Role::JSONObject
CPAN shell
perl -MCPAN -e shell install MooseX::Role::JSONObject
For more information on module installation, please visit the detailed CPAN module installation guide.