2 package MooseX::Storage::Format::JSON;
13 my ( $class, $json, @args ) = @_;
14 $class->unpack( JSON::Any->jsonToObj($json), @args );
18 my ( $self, @args ) = @_;
19 JSON::Any->objToJson( $self->pack(@args) );
30 MooseX::Storage::Format::JSON
38 with Storage('format' => 'JSON');
40 has 'x' => (is => 'rw', isa => 'Int');
41 has 'y' => (is => 'rw', isa => 'Int');
45 my $p = Point->new(x => 10, y => 10);
47 ## methods to freeze/thaw into
48 ## a specified serialization format
49 ## (in this case JSON)
51 # pack the class into a JSON string
52 $p->freeze(); # { "__CLASS__" : "Point", "x" : 10, "y" : 10 }
54 # unpack the JSON string into a class
55 my $p2 = Point->thaw('{ "__CLASS__" : "Point", "x" : 10, "y" : 10 }');
77 All complex software has bugs lurking in it, and this module is no
78 exception. If you find a bug please either email me, or add the bug
83 Chris Prather E<lt>chris.prather@iinteractive.comE<gt>
85 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
87 =head1 COPYRIGHT AND LICENSE
89 Copyright 2007 by Infinity Interactive, Inc.
91 L<http://www.iinteractive.com>
93 This library is free software; you can redistribute it and/or modify
94 it under the same terms as Perl itself.