odos')
->code_is(200)
->json_cmp([]);
$t->request(GET '/todos/1')
->code_is(404);
$t->request(
PUT '/todos',
Content_Type => 'application/json',
Content => $app->json->encode({name => 't1', co
ntent => 't1 content'})
)
->code_is(200)
->json_cmp({id => 1});
$t->request(
PUT '/todos',
Content_Type => 'application/json',
Content => $app->json->encode({name => 't2', content => 't2 conten
)
->json_cmp({id => 2});
$t->request(GET '/todos/1')
->code_is(200)
->json_cmp({name => 't1', content => 't1 content', date => ignore()});
$t->request(GET '/todos/2')
->code_is(200)
->json_cmp(
use strict;
use warnings;
use Perlgram;
use Perlgram::Update;
use Carp qw(croak);
use JSON qw(decode_json);
sub new {
my ($class, %args) = @_;
my $self = {
bot => $args
exists $_->{excluded}
? delete $_->{excluded}
: JSON::PP::false
),
# _notes => $_->{notes}
}
} @{
ngs;
use autodie;
#use Carp qw(confess);
use feature qw(say);
use utf8;
use Data::Dumper;
use JSON::XS;
use Time::HiRes qw(gettimeofday);
use POSIX qw(strftime);
use Scalar::Util qw(looks_
(shift);
return
( $val eq 'true' || $val eq 'yes' ) ? JSON::XS::true
: ( $val eq 'false' || $val eq 'no' ) ? JSON::XS::false
: undef;
##########
use Convert::Pheno;
# Define method
my $method = 'pxf2bff';
# Define data
my $my_pxf_json_data = {
"phenopacket" => {
"id" => "P0007500",
"subject" => {
}
}
} ;
# Create object
my $convert = Convert::Pheno->new(
{
data => $my_pxf_json_data,
method => $method
}
);
# Run method and store result in hashref
my $hashref =
are usually split in files:
# - phenopacket.json ( usually - 1 individual per file)
# - cohort.json (info on mutliple individuals)
# - family.json (info related to one or multiple individuals).
the root level (/).
#
# However, top-elements might be combined into a single file (e.g., pxf.json),
# as a result, certain files may contain objects for top-level elements:
# - /phenopacket
e = shift;
print Dumper $value;
return JSON::XS::true
if $value && $value ne 'false'; # Non-empty string and not 'false'
return JSON::XS::false; # Empty, 'false', or
{
my $obs;
next
if ( $feature->{excluded} && $feature->{excluded} == JSON::PP::true );
$obs->{observation_id} = ++$OBSERVATION_ID_COUNT;
# e.g., $feature
onfig->{token}) {
return $c->render(json => { error => 'Invalid token' }, status => 403);
}
my $update = $c->req->json;
if ($update) {
my $handle
iled: $@");
return $c->render(json => { error => 'Internal error' }, status => 500);
}
}
$c->render(json => { ok => 1 });
});
}
1;
__END__
e warnings;
use autodie;
use feature qw(say);
use Moo;
use File::Spec::Functions qw(catfile);
use JSON::Validator;
use Term::ANSIColor qw(:constants);
use Convert::Pheno::IO::FileIO;
# Declate attrib
er an object is created
sub BUILD {
my $self = shift;
$self->{schema} =
io_yaml_or_json( { filepath => $self->{schema_file}, mode => 'read' } )
; # setter
}
##################
##############
# SCHEMA VALIDATION #
#########################
#########################
sub json_validate {
my $self = shift;
my $data = $self->{data};
my $schema = $self->{sche
Convert::Pheno::Utils::Mapping;
use Convert::Pheno::CSV;
use Convert::Pheno::RDF qw(do_bff2jsonld do_pxf2jsonld);
use Convert::Pheno::OMOP;
use Convert::Pheno::PXF;
use Convert::Pheno::Bff2Pxf;
use Co
CDISC;
use Convert::Pheno::REDCap;
use Exporter 'import';
our @EXPORT =
qw($VERSION io_yaml_or_json omop2bff_stream_processing share_dir); # Symbols imported by default
#our @EXPORT_OK = qw(foo
#####
#############
sub bff2pxf {
my $self = shift;
# <array_dispatcher> will deal with JSON arrays
return $self->array_dispatcher;
}
#############
#############
# BFF2CSV #
#########
ing;
use strict;
use warnings;
use autodie;
use feature qw(say);
use utf8;
use Data::Dumper;
use JSON::XS;
use Time::HiRes qw(gettimeofday);
use POSIX qw(strftime);
use DateTime::Format::ISO860
(shift);
return
( $val eq 'true' || $val eq 'yes' ) ? JSON::XS::true
: ( $val eq 'false' || $val eq 'no' ) ? JSON::XS::false
: undef;
n = 'JSON::PP'; # use JSON::PP::Boolean objects
use JSON::XS;
use Sort::Naturally qw(nsort);
use Data::Leaf::Walker;
use Exporter 'import';
our @EXPORT = qw(read_json read_yaml io_yaml_or_json writ
#
#########################
#########################
sub read_json {
my $str = path(shift)->slurp_utf8;
return decode_json($str); # Decode to Perl data structure
}
sub read_yaml {
_or_json {
my $arg = shift;
my $file = $arg->{filepath};
my $mode = $arg->{mode};
my $data = $mode eq 'write' ? $arg->{data} : undef;
# Checking only for qw(.yaml .yml .json)
# from cpan
use JSON::RPC2::TwoWay 0.07;
# JSON::RPC2::TwoWay depends on JSON::MaybeXS anyways, so it can be used here
# without adding another dependency
use JSON::MaybeXS qw(JSON);
use MojoX::Nets
e JobCenter::Client::Mojo::Steps;
has [qw(
actions address auth clientid conn debug ioloop jobs json
lastping log method ns ping_timeout port rpc timeout tls token who
)];
# keep in sync with the
args{debug} // 0; # or 1?
$self->{ioloop} = $args{ioloop} // Mojo::IOLoop->singleton;
my $json = $args{json} // 1;
my $log = $args{log} // Mojo::Log->new(level => ($debug) ? 'debug' : 'info');
my
use 5.036;
use strict;
use warnings;
use experimental 'builtin';
package Types::JSONSchema::PrimativeTypes;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.001000';
use Type::Library
-base,
Type::Utils;
declare JNull,
as Undef;
declare JBoolean,
as InstanceOf[ 'boolean', 'JSON::PP::Boolean', 'JSON::XS::Boolean' ]
| ScalarRef[ Enum[ 0, 1 ] ]
| Value->create_child_type(
name
rimativeType,
as InstanceOf->of('Type::Tiny')->with_attribute_values(
library => Enum[ 'Types::JSONSchema::PrimativeTypes' ],
name => Enum[ sort map $_->name, values %primative_name_to_type ],
package Types::JSONSchema;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.001000';
use constant { true => !!1, false => !!0 };
use Type::Library
-extends => [ 'Types::JSONSchema::Primative
FmtUri
FmtUriReference
FmtIri
FmtIriReference
FmtUuid
FmtUriTemplate
FmtJsonPointer
FmtRelativeJsonPointer
FmtRegex
/;
use Types::Common -all;
use Types::Standard::ArrayRef Strings
ur @EXPORT_OK, qw(
json_eq
json_safe_dumper
jpointer_escape
schema_to_type
true
false
);
signature_for json_eq => (
method => false,
pos => [ Any, Any ],
);
sub json_eq ( $x, $y ) {
ile
my $data_mapping_file =
io_yaml_or_json( { filepath => $arg->{mapping_file}, mode => 'read' } );
# Validate mapping file against JSON schema
my $jv = Convert::Pheno::Utils::Sche
>{self_validate_schema},
schema_file => $arg->{schema_file}
}
);
$jv->json_validate;
# Remap for quick looukup
remap_assignTermIdFromHeader($data_mapping_file);
self, $data );
# Return JSON string
# - canonical has some overhead but needed for t/)
# - $fh is already utf-8, no need to encode again here
return JSON::XS->new->canonical->encode
e warnings;
use autodie;
use feature qw(say);
use Moo;
use File::Spec::Functions qw(catfile);
use JSON::Validator;
use Term::ANSIColor qw(:constants);
use Convert::Pheno::IO::FileIO;
# Declate attrib
ter an object is created
sub BUILD {
my $self = shift;
$self->{schema} =
io_yaml_or_json( { filepath => $self->{schema_file}, mode => 'read' } )
; # setter
}
##################
##############
# SCHEMA VALIDATION #
#########################
#########################
sub json_validate {
my $self = shift;
my $data = $self->{data};
my $schema = $self->{schem
n = 'JSON::PP'; # use JSON::PP::Boolean objects
use JSON::XS;
use Sort::Naturally qw(nsort);
use Data::Leaf::Walker;
use Exporter 'import';
our @EXPORT = qw(read_json read_yaml io_yaml_or_json writ
#
#########################
#########################
sub read_json {
my $str = path(shift)->slurp_utf8;
return decode_json($str); # Decode to Perl data structure
}
sub read_yaml {
; # revert floatings getting stringified by YAML::XS
return $data;
}
sub io_yaml_or_json {
my $arg = shift;
my $file = $arg->{filepath};
my $mode = $arg->{mode};
my $dat
? JSON::XS::false : JSON::XS::true;
$is_boolean++;
}
# ANy other string is excluded = 0 (i.e., included)
else {
$phenotypicFeature->{excluded} = JSON::
package Perlgram;
use strict;
use warnings;
use HTTP::Tiny;
use JSON qw(encode_json decode_json);
use URI::Escape;
use Log::Log4perl qw(:easy);
use Perlgram::Error;
our $VERSION = '0.03';
o
}
# For POST methods
else {
my $content = encode_json($params);
#print "DEBUG: POST Content: $content\n"; # Debug POST data
$url,
{
headers => { 'Content-Type' => 'application/json' },
content => $content
}
);