2 package MooseX::Storage::Format::JSON;
11 my ( $class, $json ) = @_;
12 $class->unpack( JSON::Any->jsonToObj($json) );
17 JSON::Any->objToJson( $self->pack() );
28 MooseX::Storage::Format::JSON
36 with Storage('format' => 'JSON');
38 has 'x' => (is => 'rw', isa => 'Int');
39 has 'y' => (is => 'rw', isa => 'Int');
43 my $p = Point->new(x => 10, y => 10);
45 ## methods to freeze/thaw into
46 ## a specified serialization format
47 ## (in this case JSON)
49 # pack the class into a JSON string
50 $p->freeze(); # { "__CLASS__" : "Point", "x" : 10, "y" : 10 }
52 # unpack the JSON string into a class
53 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.