NAME
MooseX::Role::JSONObject::Util - helper functions for MooseX::Role::JSONObject
DESCRIPTION
The MooseX::Role::JSONObject::Util
module provides several utility functions for the MooseX::Role::JSONObject
role.
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 aMaybe[HashRef[Int]]
attribute or['hash', 'array', 'obj', 'Some::Class']
for aHashRef[ArrayRef[Some::Class]]
attribute.Note that all types descending from
Num
are represented as'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 themeta_to_json()
andmeta_from_json()
functions (see below) with different functions passed as$objfunc
.get_value_type()
Do the actual work of
get_value()
after the attribute's type has been examined byidentify_type()
.meta_to_json()
Build a Perl hash suitable for a JSON representation of an object (or a value) of the given
Moose::Meta::Class
type. Usesget_value()
, passing a reference to itself as the function to process complex objects.meta_from_json()
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. Usesget_value()
, passing a reference to itself as the function to process complex objects.
LICENSE
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.
AUTHOR
Peter Pentchev <roam@ringlet.net>