NAME
WQS::SPARQL::Result - Processing Wikidata Query Service SPARQL result.
SYNOPSIS
use WQS::SPARQL::Result;
my $obj = WQS::SPARQL::Result->new;
my @res = $obj->result($result_hr, $vars_ar);
DESCRIPTION
Class which gets structure which is originally JSON result from Wikidata Query Service and parse values from it.
METHODS
new
my $obj = WQS::SPARQL::Result->new;
Constructor.
verbose
Verbose module flag. If enabled dumps result JSON structure to STDERR.
Default value is 0.
Returns instance of class.
result
my @res = $obj->result($result_hr, $vars_ar);
Select variables from structures and return list.
Method arguments:
$result_hr
-
Structure converted from JSON string.
$vars_ar
-
Reference to array with keys, which we need to return.
Returns list of structures with key => value pairs.
ERRORS
new():
From Class::Utils::set_params():
Unknown parameter '%s'.
result():
Type '%s' doesn't supported.
EXAMPLE
use strict;
use warnings;
use WQS::SPARQL::Result;
my $result_hr = {
'head' => {
'vars' => ['item'],
},
'results' => {
'bindings' => [{
'item' => {
'type' => 'uri',
'value' => 'http://www.wikidata.org/entity/Q27954834',
},
}],
},
};
my $obj = WQS::SPARQL::Result->new;
my @ret = $obj->result($result_hr, ['item']);
# Dump out.
foreach my $ret_hr (@ret) {
print "{\n";
foreach my $key (keys %{$ret_hr}) {
print " $key => ".$ret_hr->{$key}.",\n";
}
print "},\n";
}
# Output:
# {
# item => Q27954834,
# },
DEPENDENCIES
Class::Utils, Data::Printer, Error::Pure, URI.
SEE ALSO
- WQS::SPARQL::Query::Count
-
Simple SPARQL count query.
- WQS::SPARQL::Query::Select
-
Simple SPARQL select query.
REPOSITORY
https://github.com/michal-josef-spacek/WQS-SPARQL-Result
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© Michal Josef Špaček 2020-2023
BSD 2-Clause License
VERSION
0.03