MooseX...t::JSON(3pm)

πŸ“¦
version 0.53 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– MooseX::Storage::Format::JSON β€” a JSON serialization role πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation for MooseX...t::JSON (that's MooseX::Storage::Format::JSON if we're being formal, which we are, sometimes). It's a role. It does JSON. It's giving "I serialize your objects and I do it flawlessly." ✨


🌸 NAME 🌸

MooseX::Storage::Format::JSON β€” a JSON serialization role, no cap πŸ’…


🌈 VERSION 🌈

version 0.53 β€” that's the one, that's the moment πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

okay so watch this, we're gonna make a whole Point class and give it JSON storage powers with literally two extra lines:

package Point;
use Moose;
use MooseX::Storage;

with Storage('format' => 'JSON');

has 'x' => (is => 'rw', isa => 'Int');
has 'y' => (is => 'rw', isa => 'Int');

1;

my $p = Point->new(x => 10, y => 10);

## methods to freeze/thaw into
## a specified serialization format
## (in this case JSON)

# pack the class into a JSON string
$p->freeze(); # { "__CLASS__" : "Point", "x" : 10, "y" : 10 }

# unpack the JSON string into a class
my $p2 = Point->thaw('{ "__CLASS__" : "Point", "x" : 10, "y" : 10 }');

look at her. Point->new(x => 10, y => 10) and then freeze just hands you back a whole JSON string with the class name baked in as "__CLASS__". iconic. and thaw takes that string and resurrects the object like nothing ever happened. main character energy fr fr 🫢


πŸ‘‘ METHODS πŸ‘‘

freeze πŸ’–

packs the class into a JSON string. that's the whole job, she does it gorgeously.

thaw ($json) πŸ’–

takes that JSON string (the $json argument right there, don't forget her) and unpacks it back into a class. reverse uno card, but make it serialization.


πŸŽ€ SUPPORT πŸŽ€

got beef? found a bug? bestie, they wanna hear about it πŸ›

  • Bugs may be submitted through the RT bug tracker at <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Storage> (or you can email bug-MooseX-Storage@rt.cpan.org if email is more your vibe).
  • There is also a mailing list available for users of this distribution, right here: <http://lists.perl.org/list/moose.html>. join the chat, it's cute.
  • There is also an irc channel available for users of this distribution, at "#moose" on "irc.perl.org" β€” that's <irc://irc.perl.org/#moose>, come hang out πŸ’¬

🧚 AUTHORS 🧚

the legends themselves, give them their flowers 🌸

  • Chris Prather <chris.prather@iinteractive.com>
  • Stevan Little <stevan.little@iinteractive.com>
  • Χ™Χ•Χ‘Χœ Χ§Χ•Χ’'מן (Yuval Kogman) <nothingmuch@woobling.org>

This software is copyright (c) 2007 by Infinity Interactive, Inc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt πŸ’…


and that's the whole page, bestie. this little icon was rendered by perl v5.36.0 and dated 2022-10-16, and it lives its life under the manual name MooseX...t::JSON(3pm). obsessed with her, honestly πŸ¦‹βœ¨πŸ’œ

πŸ“¦ where this page comes from