Wikibase::Datatype::Struct::Value::Property - Wikibase property structure serialization.
use Wikibase::Datatype::Struct::Value::Property 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::Property instance to structure.
Returns reference to hash with structure.
struct2obj
my $obj = struct2obj($struct_hr);
Convert structure of property to object.
Returns Wikibase::Datatype::Value::Property instance.
obj2struct(): Object doesn't exist. Object isn't 'Wikibase::Datatype::Value::Property'. struct2obj(): Structure isn't for 'property' datatype.
use strict; use warnings; use Data::Printer; use Wikibase::Datatype::Value::Property; use Wikibase::Datatype::Struct::Value::Property qw(obj2struct); # Object. my $obj = Wikibase::Datatype::Value::Property->new( 'value' => 'P123', ); # Get structure. my $struct_hr = obj2struct($obj); # Dump to output. p $struct_hr; # Output: # \ { # type "wikibase-entityid", # value { # entity-type "property", # id "P123", # numeric-id 123 # } # }
use strict; use warnings; use Wikibase::Datatype::Struct::Value::Property qw(struct2obj); # Property structure. my $struct_hr = { 'type' => 'wikibase-entityid', 'value' => { 'entity-type' => 'property', 'id' => 'P123', 'numeric-id' => 123, }, }; # Get object. my $obj = struct2obj($struct_hr); # Get value. my $value = $obj->value; # Get type. my $type = $obj->type; # Print out. print "Type: $type\n"; print "Value: $value\n"; # Output: # Type: property # Value: P123
Error::Pure, Exporter, Readonly, Wikibase::Datatype::Value::Property.
Wikibase structure serialization.
Wikibase property 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-2021
BSD 2-Clause License
0.07
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.