Wikibase::Datatype::Struct::Value::String - Wikibase string structure serialization.
use Wikibase::Datatype::Struct::Value::String qw(obj2struct struct2obj); my $struct_hr = obj2struct($obj); my $obj = struct2obj($struct_hr);
This conversion is between objects defined in Wikibase::Datatype and structures serialized via JSON to MediaWiki.
obj2struct
my $struct_hr = obj2struct($obj);
Convert Wikibase::Datatype::Value::String instance to structure.
Returns reference to hash with structure.
struct2obj
my $obj = struct2obj($struct_hr);
Convert structure of string to object.
Returns Wikibase::Datatype::Value::String instance.
obj2struct(): Object isn't 'Wikibase::Datatype::Value::String'. struct2obj(): Structure isn't for 'string' datatype.
use strict; use warnings; use Data::Printer; use Wikibase::Datatype::Value::String; use Wikibase::Datatype::Struct::Value::String qw(obj2struct); # Object. my $obj = Wikibase::Datatype::Value::String->new( 'value' => 'foo', ); # Get structure. my $struct_hr = obj2struct($obj); # Dump to output. p $struct_hr; # Output: # \ { # type "string", # value "foo" # }
use strict; use warnings; use Wikibase::Datatype::Struct::Value::String qw(struct2obj); # String structure. my $struct_hr = { 'type' => 'string', 'value' => 'foo', }; # Get object. my $obj = struct2obj($struct_hr); # Get type. my $type = $obj->type; # Get value. my $value = $obj->value; # Print out. print "Type: $type\n"; print "Value: $value\n"; # Output: # Type: string # Value: foo
Error::Pure, Exporter, Readonly, Wikibase::Datatype::Value::String.
Wikibase structure serialization.
Wikibase string value datatype.
https://github.com/michal-josef-spacek/Wikibase-Datatype-Struct
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz
© Michal Josef Špaček 2020
BSD 2-Clause License
0.01
To install Wikibase::Datatype::Struct, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Wikibase::Datatype::Struct
CPAN shell
perl -MCPAN -e shell install Wikibase::Datatype::Struct
For more information on module installation, please visit the detailed CPAN module installation guide.