package Dallycot::Value::JSON;
our $AUTHORITY = 'cpan:JSMITH';
# ABSTRACT: Manages a memory-based JSON object
use strict;
use warnings;
use utf8;
use parent 'Dallycot::Value::Any';
use experimenta
use Promises qw(deferred);
=head1 DESCRIPTION
A JSON value represents a collection of properties and values.
Long term, a JSON value will be a JSON-LD document that can be interpreted
as a set of t
package Dallycot::JSON::LD;
our $AUTHORITY = 'cpan:JSMITH';
use Moose;
use utf8;
use Carp qw(croak);
use Promises qw(deferred);
use experimental qw(switch);
sub to_rdf {
my($self, $input, %opti
container_mapping($active_property) eq '@list') {
croak "List of lists detected in JSON-LD";
}
}
push @result, grep { defined } @xp;
}
if
d_nodes;
}
=method to_json
Returns a Perl Hash containing the JSON-LD representation of the node and
any child nodes.
=cut
sub to_json {
my ($self) = @_;
croak "to_json not defined for " . (
ub json_object {
my ( undef, $prop_list ) = @_;
# my @props = map {
# _convert_to_json_array($_)
# } @$prop_list;
my @props = @$prop_list;
return bless \@props => 'Dallycot::AST::JSONOb
b _convert_to_json_array {
# my($ast) = @_;
#
# if($ast -> isa('Dallycot::AST::Assign') && $ast->[1]->isa('Dallycot::AST::BuildList')) {
# bless $ast->[1] => 'Dallycot::AST::JSONArray';
# }
# return $ast;
# }
sub json_prop_list {
my( undef, @props ) = @_;
return \@props;
}
sub json_prop {
my( undef, $string, $value ) = @_;
if(blessed($value) && $value->isa('Dallycot::AST::B
return $type;
}
sub simplify {
my ($self) = @_;
return $self;
}
sub to_json {
my ($self) = @_;
croak "to_json not defined for " . ( blessed($self) || $self );
}
sub to_string {
my ($se
package Dallycot::AST::JSONObject;
our $AUTHORITY = 'cpan:JSMITH';
# ABSTRACT: Create JSON-LD graph from JSON
use strict;
use warnings;
use utf8;
use parent 'Dallycot::AST';
use experimental qw(sw
es qw(deferred);
sub execute {
my ( $self, $engine ) = @_;
return $engine->collect(@$self)->then(sub {
my(%properties) = @_;
return Dallycot::Value::JSON->new(\%properties);
});
}
1;
return a promise that will be fulfilled with the parsed/extracted
RDF as a simple graph. Different backends will parse data from
different sources.
In order of preference:
- JSON-LD
- RDF/XML
- RDFa
strict;
use warnings;
use utf8;
use parent 'Dallycot::AST';
use Promises qw(deferred);
sub to_json {
return +{ a => 'Expr' };
}
sub to_string { return "" }
sub to_rdf {
}
sub execute {
my
a JSON-LD
document. This makes the examples easier to write. There's no reason
you can't publish as RDF/XML or some other serialization that supports
RDF.
Dallycot allows you to embed code in a JSON
even easier to write:
{
"@context": [
<https://www.dhdata.org/ns/linked-code/1.0.json>,
{
ns:l := <http://www.example.com/our-library#>,
@base: <http://www.ex
e in the scope of the array will become
JSON objects with the identifier as the C<@id>. If the scope were a JSON
object instead of an array, then the same JSON objects would be made, but
the C<@id> w
strict;
use warnings;
use utf8;
use parent 'Dallycot::AST';
use Promises qw(deferred);
sub to_json {
}
sub to_string { return "" }
sub is_declarative { return 1 }
sub identifier { }
sub as_tex
package Dallycot::AST::JSONArray;
our $AUTHORITY = 'cpan:JSMITH';
# ABSTRACT: Create JSON-LD graph from JSON
use strict;
use warnings;
use utf8;
use parent 'Dallycot::AST';
use experimental qw(swi
package Dallycot::AST::JSONProperty;
our $AUTHORITY = 'cpan:JSMITH';
# ABSTRACT: Create JSON-LD graph from JSON
use strict;
use warnings;
use utf8;
use parent 'Dallycot::AST';
use experimental qw(
3.org/TR/ldp/>
for an example of the kind of data services Dallycot will target. Dallycot
prefers JSON-LD when communicating with services.
Dallycot is not a query language. Projects like L<Marmotta|