Toolforge::MixNMatch::Struct::User - Mix'n'match user structure serialization.
use Toolforge::MixNMatch::Struct::User qw(obj2struct struct2obj); my $struct_hr = obj2struct($obj); my $obj = struct2obj($struct_hr);
This conversion is between object defined in Toolforge::MixNMatch::Object::User and structure serialized via JSON to Mix'n'match application.
obj2struct
my $struct_hr = obj2struct($obj);
Convert Toolforge::MixNMatch::Object::User instance to structure.
Returns reference to hash with structure.
struct2obj
my $obj = struct2obj($struct_hr);
Convert structure of time to object.
Returns Toolforge::MixNMatch::Object::User instance.
obj2struct(): Object doesn't exist. Object isn't 'Toolforge::MixNMatch::Object::User'.
use strict; use warnings; use Data::Printer; use Toolforge::MixNMatch::Object::User; use Toolforge::MixNMatch::Struct::User qw(obj2struct); # Object. my $obj = Toolforge::MixNMatch::Object::User->new( 'count' => 6, 'uid' => 1, 'username' => 'Skim', ); # Get structure. my $struct_hr = obj2struct($obj); # Dump to output. p $struct_hr; # Output: # \ { # cnt 6, # uid 1, # username "Skim" # }
use strict; use warnings; use Toolforge::MixNMatch::Struct::User qw(struct2obj); # Time structure. my $struct_hr = { 'cnt' => 6, 'uid' => 1, 'username' => 'Skim', }; # Get object. my $obj = struct2obj($struct_hr); # Get count. my $count = $obj->count; # Get user UID. my $uid = $obj->uid; # Get user name. my $username = $obj->username; # Print out. print "Count: $count\n"; print "User UID: $uid\n"; print "User name: $username\n"; # Output: # Count: 6 # User UID: 1 # User name: Skim
Error::Pure, Exporter, Readonly, Toolforge::MixNMatch::Struct::User.
Toolforge Mix'n'match tool structures.
https://github.com/michal-josef-spacek/Toolforge-MixNMatch-Struct
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz
© Michal Josef Špaček 2020
BSD 2-Clause License
0.04
To install Toolforge::MixNMatch::Struct, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Toolforge::MixNMatch::Struct
CPAN shell
perl -MCPAN -e shell install Toolforge::MixNMatch::Struct
For more information on module installation, please visit the detailed CPAN module installation guide.