:Parser> - RDF parsers for various serialization formats including RDF/XML, Turtle, RDFa, and RDF/JSON.
=item
L<RDF::Trine::Store::Memory> - An in-memory, non-persistant triple store. Typically use
::Util qw(first);
use Scalar::Util qw(refaddr reftype blessed);
use HTTP::Request::Common ();
use JSON;
use RDF::Trine::Error qw(:try);
##############################################################
ccept = join(',',
"application/sparql-results+json",
"application/rdf+xml;q=0.5",
"application/x-turtle;q=0.7",
"application/json;q=0.4",
"text/turtle;q=0.7",
"text/xml;q
/json");
$req->header(Host => "dydra.com");
$req->authorization_basic($self->{token}) if (defined $self->{token});
my $resp = $ua->request( $req );
if ($resp->is_success) {
my $data = from_json(
e XML::SAX;
use RDF::Trine::Node;
use RDF::Trine::Iterator::SAXHandler;
use RDF::Trine::Iterator::JSONHandler;
our ($VERSION, @ISA, @EXPORT_OK);
BEGIN {
$VERSION = '1.019';
require Exporter;
@IS
issing, defaults to XML serialization.
Other options are:
http://www.w3.org/2001/sw/DataAccess/json-sparql/
=cut
sub to_string {
my $self = shift;
my $format = shift || 'http://www.w3.org/2005/
$format->as_string;
}
if ($format eq 'http://www.w3.org/2001/sw/DataAccess/json-sparql/') {
return $self->as_json;
} else {
return $self->as_xml;
}
}
=item C<< from_string ( $xml ) >>
Ret
# RDF::Trine::Parser::RDFJSON
# -----------------------------------------------------------------------------
=head1 NAME
RDF::Trine::Parser::RDFJSON - RDF/JSON RDF Parser
=head1 VERSION
This docu
ment describes RDF::Trine::Parser::RDFJSON version 1.019
=head1 SYNOPSIS
use RDF::Trine::Parser;
my $parser = RDF::Trine::Parser->new( 'RDF/JSON' );
$parser->parse_into_model( $base_uri, $data, $
rits methods from the
L<RDF::Trine::Parser> class.
=over 4
=cut
package RDF::Trine::Parser::RDFJSON;
use strict;
use warnings;
no warnings 'redefine';
no warnings 'once';
use base qw(RDF::Trine::P
@args );
}
=item C<< add_hashref ( $hashref [, $context] ) >>
Add triples represented in an RDF/JSON-like manner to the model.
See C<< as_hashref >> for full documentation of the hashref format.
=
ts( qw(s p o g) );
}
=item C<< as_hashref >>
Returns a hashref representing the model in an RDF/JSON-like manner.
A graph like this (in Turtle):
@prefix ex: <http://example.com/> .
ex:subje
the convention of starting blank nodes with "_:".
This hashref structure is compatible with RDF/JSON and with the ARC2
library for PHP.
=cut
sub as_hashref {
my $self = shift;
$self->end_bulk_op
cut
package RDF::Trine::Iterator::Graph;
use strict;
use warnings;
no warnings 'redefine';
use JSON;
use List::Util qw(max);
use Scalar::Util qw(blessed);
use RDF::Trine::Iterator qw(sgrep);
use R
tion>\n];
}
print {$fh} "</rdf:RDF>\n";
}
=item C<as_json ( $max_size )>
Returns a JSON serialization of the stream data.
=cut
sub as_json {
my $self = shift;
my $max_result_size = shift;
t
Error ( -text => 'There is no JSON serialization specified for graph query results' );
}
=item C<< as_hashref >>
Returns a hashref representing the model in an RDF/JSON-like manner.
See C<< as_hash
# RDF::Trine::Serializer::RDFJSON
# -----------------------------------------------------------------------------
=head1 NAME
RDF::Trine::Serializer::RDFJSON - RDF/JSON Serializer
=head1 VERSION
T
describes RDF::Trine::Serializer::RDF/JSON version 1.019
=head1 SYNOPSIS
use RDF::Trine::Serializer::RDFJSON;
my $serializer = RDF::Trine::Serializer::RDFJSON->new();
=head1 DESCRIPTION
The RDF:
RDF/JSON syntax.
=head1 METHODS
Beyond the methods documented below, this class inherits methods from the
L<RDF::Trine::Serializer> class.
=over 4
=cut
package RDF::Trine::Serializer::RDFJSON;
u
:Iterator::JSONHandler
# -----------------------------------------------------------------------------
=head1 NAME
RDF::Trine::Iterator::JSONHandler - JSON Handler for parsing SPARQL JSON Results fo
rmat
=head1 VERSION
This document describes RDF::Trine::Iterator::JSONHandler version 1.019
=head1 STATUS
This module's API and functionality should be considered unstable.
In the future, this mod
e::Iterator::JSONHandler;
my $handler = RDF::Trine::Iterator::JSONHandler->new();
my $iter = $handler->parse( $json );
=head1 METHODS
=over 4
=cut
package RDF::Trine::Iterator::JSONHandler;
use
oreUtils qw(zip);
use Scalar::Util qw(refaddr reftype blessed);
use HTTP::Request::Common ();
use JSON;
use RDF::Trine::Error qw(:try);
##############################################################
model );
}
=item C<< add_hashref ( $hashref [, $context] ) >>
Add triples represented in an RDF/JSON-like manner to the model.
=cut
sub add_hashref {
my $self = shift;
return $self->model->add_h
ut
package RDF::Trine::Iterator::Boolean;
use strict;
use warnings;
no warnings 'redefine';
use JSON 2.0;
use base qw(RDF::Trine::Iterator);
our ($VERSION);
BEGIN {
$VERSION = '1.019';
}
=item C<
_json ( $max_size )>
Returns a JSON serialization of the stream data.
=cut
sub as_json {
my $self = shift;
my $max_result_size = shift || 0;
my $value = $self->get_boolean ? JSON::true : JSON:
:false;
my $data = { head => { vars => [] }, boolean => $value };
return to_json( $data );
}
=item C<< construct_args >>
Returns the arguments necessary to pass to the stream constructor _new
to r
or::Bindings;
use utf8;
use strict;
use warnings;
no warnings 'redefine';
use Data::Dumper;
use JSON 2.0;
use Text::Table;
use Log::Log4perl;
use Scalar::Util qw(blessed reftype);
use RDF::Trine::It
indings {
my $self = shift;
return 1;
}
=item C<as_json ( $max_size )>
Returns a JSON serialization of the stream data.
=cut
sub as_json {
my $self = shift;
my $max_result_size = shift ||
@sorted = $self->sorted_by;
my $order = scalar(@sorted) ? JSON::true : JSON::false;
my $dist = $self->_args->{distinct} ? JSON::true : JSON::false;
my $data = {
head => { vars => \@variables
>_compare( $b );
}
}
=item C<< as_hashref >>
Returns a hashref representing the node in an RDF/JSON-like manner.
See C<< as_hashref >> at L<RDF::Trine::Model> for full documentation of the
hashref