On 15.2.2011 15:04, Stevan Little wrote:
I'm pondering what way to use to serialize my Moose classes to JSON. I've have been
looking to MooseX::Storage but it seems it cannot handle more than basic attribute types.
Just the very first class I tried: "Cannot handle type constraint
(MooseX::Types::URI::Uri)"
There seems to be a way to add custom handlers, but the documentation is scarce.
I also tried the MooseX::Storage::Format::JSONpm, but the result is the same.
Sorry, this feature never really got properly documented, but patches are
always welcome, and doc patches are especially welcome.
What you want to do is to look at the methods listed here:
http://search.cpan.org/~bobtfish/MooseX-Storage-0.29/lib/MooseX/Storage/Engine.pm#Type_Constraint_Handlers
Hello,
I was wondering, if there is no serialization handler for a type like
for example "MooseX::Types::URI::Uri" in this case.
What we need to serialize is not really "MooseX::Types::URI::Uri" but
URI object, which has its own stringification method.
One doesn't really need more to serialize constraints like
MooseX::Types::URI or MooseX::Types::Path::Class.
Would it make sense as a last resort to check whether object has its own
stringification method and use that before it gives up and dies?
Or am I just totally off base?
Kind Regards