NAME
Wikibase::Datatype::Struct::Value::Sense - Wikibase sense value structure serialization.
SYNOPSIS
use Wikibase::Datatype::Struct::Value::Sense 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::Sense instance to structure.
Returns reference to hash with structure.
struct2obj
my $obj = struct2obj($struct_hr);
Convert structure of sense to object.
Returns Wikibase::Datatype::Value::Sense instance.
ERRORS
obj2struct():
Object doesn't exist.
Object isn't 'Wikibase::Datatype::Value::Sense'.
struct2obj():
Structure isn't for 'sense' datatype.
EXAMPLE1
use strict;
use warnings;
use Data::Printer;
use Wikibase::Datatype::Value::Sense;
use Wikibase::Datatype::Struct::Value::Sense qw(obj2struct);
# Object.
my $obj = Wikibase::Datatype::Value::Sense->new(
'value' => 'L34727-S1',
);
# Get structure.
my $struct_hr = obj2struct($obj);
# Dump to output.
p $struct_hr;
# Output:
# \ {
# type "wikibase-entityid",
# value {
# entity-type "sense",
# id "L34727-S1",
# }
# }
EXAMPLE2
use strict;
use warnings;
use Wikibase::Datatype::Struct::Value::Sense qw(struct2obj);
# Property structure.
my $struct_hr = {
'type' => 'wikibase-entityid',
'value' => {
'entity-type' => 'sense',
'id' => 'L34727-S1',
},
};
# 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: sense
# Value: L34727-S1
DEPENDENCIES
Error::Pure, Exporter, Readonly, Wikibase::Datatype::Value::Sense.
SEE ALSO
- Wikibase::Datatype::Struct
-
Wikibase structure serialization.
- Wikibase::Datatype::Value::Sense
-
Wikibase sense 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-2023 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.12