package JMAP::Validation::Tests::Boolean;
use strict;
use warnings;
sub is_boolean{
my ($value) = @_;
return (ref($value) || '') eq 'JSON::PP::Boolean';
}
1;
read_text);
use Hash::DefHash;
use JSON::MaybeXS;
sub munge_files {
no strict 'refs';
my $self = shift;
find sub {
return unless -f && /\.json\z/;
my $ct = read_text $_;
my $hash;
eval { $hash = decode_json($ct) };
$self->log_fatal(["File %s doesn't contain a valid JSON: %s", "$File::Find::dir/$_", $@])
if $@;
my $defhash;
s>). Currently it does the following:
=over
=item * For C<share/examples/*.json>, check that the file contains valid JSON and valid defhash (or invalid defhash, if filename begins with 'error-')
=b
:Array;
# data types {{{
sub is_string {
my ($value) = @_;
return (ref($value) || '') eq 'JSON::Typist::String';
}
# }}}
# restrictions {{{
sub has_at_least_one_character {
my ($value) =
nerators::ContactGroup;
use strict;
use warnings;
use JMAP::Validation::Generators::String;
use JSON::Typist;
sub generate {
my (%args) = @_;
my @contactIds
= map { JMAP::Validation::Gener
elds in the dataset
cat data.json | catmandu convert -v JSON to Stat --fields isbn
# Export the statistics as YAML
cat data.json | catmandu convert -v JSON to Stat --fields isbn --as YAML
a.json | catmandu convert JSON to Stat --fields title
# Calculate statistics on the number of records that contain a 'title', 'isbn' or 'subject' fields
cat data.json | catmandu convert JSON
t data.json | catmandu convert JSON to Stat --fields foo.bar.x.y
When no fields parameter is available, then all fields are read from the first input record.
=item as Table | CSV | YAML | JSON | ...
package JMAP::Validation::Tests::Number;
use strict;
use warnings;
sub is_number {
my ($value) = @_;
return (ref($value) || '') eq 'JSON::Typist::Number';
}
1;
tactInformation;
use strict;
use warnings;
use JMAP::Validation::Generators::String;
use JSON::PP;
use JSON::Typist;
my %types = (
emails => [qw{
personal
work
other
}],
phones =>
>generate(), undef) {
foreach my $isDefault (JSON::PP::true, JSON::PP::false) {
push @ContactInformation, {
type => JSON::Typist::String->new($type_value),
label
tion::Generators::File;
use strict;
use warnings;
use JMAP::Validation::Generators::String;
use JSON::Typist;
sub generate {
my $blobId = 1;
my @files;
foreach my $type (JMAP::Validation::G
each my $name (JMAP::Validation::Generators::String->generate(), undef) {
foreach my $size (JSON::Typist::Number->new(int(rand(2**32))), undef) {
push @files, {
blobId => JMAP:
ion;
use JMAP::Validation::Generators::File;
use JMAP::Validation::Generators::String;
use JSON::PP;
use JSON::Typist;
sub generate {
my ($type) = @_;
my @avatars = (
JMAP::Validation::Gener
Generators::Address::generate()],
[],
);
my @Contacts;
foreach my $isFlagged (JSON::PP::true, JSON::PP::false) {
foreach my $avatar (@avatars) {
foreach my $email (@{$ContactInfo
String->generate(),
birthday => JSON::Typist::String->new(fake_past_datetime('%Y-%m-%d')->()),
anniversary => JSON::Typist::String->new(fake_past_datetime('%Y-%m-%d'
JMAP::Validation::Generators::ContactGroup;
use JMAP::Validation::Generators::String;
use JSON::PP;
use JSON::Typist;
use Test2::Bundle::Extended;
use Test::Deep qw{eq_deeply};
my (
%ACCOUNT,
%S
ators::real(),
array => [],
object => {},
ok => JSON::PP::null,
}->{$test->{ifInState}},
create => {
true => JMAP::
mit') {
$request_args{accountId} = {
supplied => $ACCOUNT{accountId},
null => JSON::PP::null,
}->{$test->{accountId}};
}
my $contactGroups = $ACCOUNT{jmap}->request([["get
{{
our $is_string = validator(sub {
my (%params) = @_;
return (ref($params{got}) || '') eq 'JSON::Typist::String';
});
# }}}
# restrictions {{{
our $is_string_or_null = in_set($is_string, U()
::ContactGroup;
use JMAP::Validation::Checks::Error;
use JMAP::Validation::Generators;
use JSON::PP;
use JSON::Typist;
use Test2::Bundle::Extended;
use Test::Deep qw{eq_deeply};
my (
%ACCOUNT,
$S
mit') {
$request_args{accountId} = {
supplied => $ACCOUNT{accountId},
null => JSON::PP::null,
}->{$test->{accountId}};
}
unless ($test->{ids} eq 'omit') {
$request_arg
l_not_found => [qw{these ids do not exist}],
empty => [],
null => JSON::PP::null,
}->{$test->{ids}};
}
return \%request_args;
}
sub _build_error_response {
Validation::Generators::String;
use strict;
use warnings;
use Data::Fake::Text;
use JSON::PP;
use JSON::Typist;
sub generate {
return JSON::Typist::String->new(join '', fake_words(4)->());
}
1;
::Number;
use Test2::Bundle::Extended;
use JSON::Typist;
our $is_number = validator(sub {
my (%params) = @_;
return (ref($params{got}) || '') eq 'JSON::Typist::Number';
});
our $is_number_or_n
Calculate statistics on the availabity of the ISBN fields in the dataset
cat data.json | catmandu convert JSON to Stat --fields isbn
# Preprocess data and calculate statistics
catmandu co
is);
# prefix
$self->prefix($self->key ? $self->key : 'socket.io');
}
sub json { $_[0]->flags->{json} = 1; $_[0]; }
sub volatile { $_[0]->flags->{volatile} = 1; $_[0]; }
sub bro
gs;
use JSON::PP;
use JSON::Typist;
use JMAP::Validation::Generators::String;
sub true {
return JSON::PP::true;
}
sub false {
return JSON::PP::false;
}
sub negative_int {
return JSON::Typist
eturn JSON::Typist::Number->new(0-(rand 2**64));
}
sub zero {
return JSON::Typist::Number->new(0);
}
sub int {
return JSON::Typist::Number->new(int(rand 2**64));
}
sub real {
return JSON::Typ
and a response
# (Responds to URL /foobar.json, returns JSON content '{"foo":"bar"}')
$imposter->stub->predicate(
path => "/foobar.json",
method => "GET",
)->response(
atus_code => 200,
content_type => "application/json",
# Equivalent:
# headers => { Content_Type => "application/json" },
body => { foo => "bar" },
#
->predicate(
path => "/qux/999/json",
method => "GET",
)->response(
status_code => 404,
content_type => "application/json",
body => '{ "error": "
e warnings;
use 5.010;
our $VERSION = '0.06'; # VERSION
use Moo;
use CGI;
use Data::Dumper;
use JSON;
use Try::Tiny;
use Digest::SHA qw(hmac_sha1_hex);
use File::ShareDir qw(module_dir);
use File::C
>param('POSTDATA');
} else {
return;
}
}
has payload_json => (
is => 'lazy',
);
sub _build_payload_json {
my $self = shift;
my $q = $self->cgi;
my $payload =
});
if ($self->payload) {
$payload = $self->payload;
try {
decode_json($payload);
} catch {
s/\"/\'/g; s/\n/ /gs;
$payload = qq({"error"
return '';
};
get '/map' => sub {
return to_json( $webio->pin_desc( $default_name ) );
};
get qr{\A / \* }x => sub {
return to_json( $webio->all_desc( $default_name ) );
};
get '/' =>
s point, you should be able to startup Apache. Calling
C<http://example.com/*> should get you a JSON dump of the pins. Calling
C<http://example.com/app/app/gpio-header/index.html> should get you a