1MooseX::Storage::FormatU:s:eJrSOCNo(n3t)ributed Perl DocMuomoesnetXa:t:iSotnorage::Format::JSON(3)
2
3
4
6 MooseX::Storage::Format::JSON - A JSON serialization role
7
9 package Point;
10 use Moose;
11 use MooseX::Storage;
12
13 with Storage('format' => 'JSON');
14
15 has 'x' => (is => 'rw', isa => 'Int');
16 has 'y' => (is => 'rw', isa => 'Int');
17
18 1;
19
20 my $p = Point->new(x => 10, y => 10);
21
22 ## methods to freeze/thaw into
23 ## a specified serialization format
24 ## (in this case JSON)
25
26 # pack the class into a JSON string
27 $p->freeze(); # { "__CLASS__" : "Point", "x" : 10, "y" : 10 }
28
29 # unpack the JSON string into a class
30 my $p2 = Point->thaw('{ "__CLASS__" : "Point", "x" : 10, "y" : 10 }');
31
33 freeze
34 thaw ($json)
35
36 Introspection
37 meta
38
40 All complex software has bugs lurking in it, and this module is no
41 exception. If you find a bug please either email me, or add the bug to
42 cpan-RT.
43
45 Chris Prather <chris.prather@iinteractive.com>
46
47 Stevan Little <stevan.little@iinteractive.com>
48
49 Yuval Kogman <yuval.kogman@iinteractive.com>
50
52 Copyright 2007-2008 by Infinity Interactive, Inc.
53
54 <http://www.iinteractive.com>
55
56 This library is free software; you can redistribute it and/or modify it
57 under the same terms as Perl itself.
58
59
60
61perl v5.12.0 2009-07-14 MooseX::Storage::Format::JSON(3)