NAME

MooseX::Role::JSONObject - create/store an object in a JSON-like hash

SYNOPSIS

package foo;

use Moose;
with 'MooseX::Role::JSONObject';

...

my $obj = foo->new(...);
my $data = $obj->to_json();
...
my $newobj = foo->from_json($data);

DESCRIPTION

The MooseX::Role::JSONObject role provides two methods, to_json() and from_json(), for storing and retrieving a Moose object's attributes and, if they are Moose objects themselves, their attributes recursively. This is mainly useful in two cases: creating an object and all of its attributes from a hash parsed from a JSON string or storing an object and all its attributes as a hash to be written to a JSON string.

METHODS

The MooseX::Role::JSONObject role provides two methods:

SEE ALSO

MooseX::Role::JSONObject::Meta::Trait

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