Wikibase::Datatype::Struct::Value::Monolingual - Wikibase monolingual structure serialization.
use Wikibase::Datatype::Struct::Value::Monolingual 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::Monolingual instance to structure.
Returns reference to hash with structure.
struct2obj
my $obj = struct2obj($struct_hr);
Convert structure of monolingual to object.
Returns Wikibase::Datatype::Value::Monolingual instance.
obj2struct(): Object doesn't exist. Object isn't 'Wikibase::Datatype::Value::Monolingual'. struct2obj(): Structure isn't for 'monolingualtext' datatype.
use strict; use warnings; use Data::Printer; use Wikibase::Datatype::Value::Monolingual; use Wikibase::Datatype::Struct::Value::Monolingual qw(obj2struct); # Object. my $obj = Wikibase::Datatype::Value::Monolingual->new( 'language' => 'en', 'value' => 'English text', ); # Get structure. my $struct_hr = obj2struct($obj); # Dump to output. p $struct_hr; # Output: # \ { # type "monolingualtext", # value { # language "en", # text "English text" # } # }
use strict; use warnings; use Wikibase::Datatype::Struct::Value::Monolingual qw(struct2obj); # Monolingualtext structure. my $struct_hr = { 'type' => 'monolingualtext', 'value' => { 'language' => 'en', 'text' => 'English text', }, }; # Get object. my $obj = struct2obj($struct_hr); # Get language. my $language = $obj->language; # Get type. my $type = $obj->type; # Get value. my $value = $obj->value; # Print out. print "Language: $language\n"; print "Type: $type\n"; print "Value: $value\n"; # Output: # Language: en # Type: monolingualtext # Value: English text
Error::Pure, Exporter, Readonly, Wikibase::Datatype::Value::Monolingual.
Wikibase structure serialization.
Wikibase monolingual value datatype.
https://github.com/michal-josef-spacek/Wikibase-Datatype-Struct
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz
© 2020-2022 Michal Josef Špaček
BSD 2-Clause License
0.09
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.