NAME
Wikibase::Datatype::Struct::Value::Lexeme - Wikibase lexeme value structure serialization.
SYNOPSIS
use Wikibase::Datatype::Struct::Value::Lexeme qw(obj2struct struct2obj);
my $struct_hr = obj2struct($obj);
my $obj = struct2obj($struct_hr);
DESCRIPTION
This conversion is between objects defined in Wikibase::Datatype and structures serialized via JSON to MediaWiki.
SUBROUTINES
obj2struct
my $struct_hr = obj2struct($obj);
Convert Wikibase::Datatype::Value::Lexeme instance to structure.
Returns reference to hash with structure.
struct2obj
my $obj = struct2obj($struct_hr);
Convert structure of item to object.
Returns Wikibase::Datatype::Value::Lexeme instance.
ERRORS
obj2struct():
Object doesn't exist.
Object isn't 'Wikibase::Datatype::Value::Lexeme'.
struct2obj():
Structure isn't for 'lexeme' datatype.
EXAMPLE1
use strict;
use warnings;
use Data::Printer;
use Wikibase::Datatype::Value::Lexeme;
use Wikibase::Datatype::Struct::Value::Lexeme qw(obj2struct);
# Object.
my $obj = Wikibase::Datatype::Value::Lexeme->new(
'value' => 'L42284',
);
# Get structure.
my $struct_hr = obj2struct($obj);
# Dump to output.
p $struct_hr;
# Output:
# \ {
# type "wikibase-entityid",
# value {
# entity-type "lexeme",
# id "L42284",
# numeric-id 42284
# }
# }
EXAMPLE2
use strict;
use warnings;
use Wikibase::Datatype::Struct::Value::Lexeme qw(struct2obj);
# Item structure.
my $struct_hr = {
'type' => 'wikibase-entityid',
'value' => {
'entity-type' => 'lexeme',
'id' => 'L42284',
'numberic-id' => 42284,
},
};
# 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: lexeme
# Value: L42284
DEPENDENCIES
Error::Pure, Exporter, Readonly, Wikibase::Datatype::Value::Lexeme.
SEE ALSO
- Wikibase::Datatype::Struct
-
Wikibase structure serialization.
- Wikibase::Datatype::Value::Item
-
Wikibase item value datatype.
REPOSITORY
https://github.com/michal-josef-spacek/Wikibase-Datatype-Struct
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2020-2024 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.13