WQS::SPARQL::Result - Processing Wikidata Query Service SPARQL result.
use WQS::SPARQL::Result; my $obj = WQS::SPARQL::Result->new; my @res = $obj->result($result_hr, $vars_ar);
Class which gets structure which is originally JSON result from Wikidata Query Service and parse values from it.
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.
new(): From Class::Utils::set_params(): Unknown parameter '%s'. result(): Type '%s' doesn't supported.
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, # },
Class::Utils, Data::Printer, Error::Pure, URI.
Simple SPARQL count query.
Simple SPARQL select query.
https://github.com/michal-josef-spacek/WQS-SPARQL-Result
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz
© Michal Josef Špaček 2020-2023
BSD 2-Clause License
0.03
To install WQS::SPARQL::Result, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WQS::SPARQL::Result
CPAN shell
perl -MCPAN -e shell install WQS::SPARQL::Result
For more information on module installation, please visit the detailed CPAN module installation guide.