ct;
use utf8;
use Carp qw[carp croak];
use Data::UUID;
use Digest::MD5 qw[md5_hex];
use DBI;
use JSON qw[];
use overload qw[];
use RDF::Trine qw[statement blank literal];
use RDF::Trine::Namespace qw
my $rv;
unless ($options{no_json})
{
my $json = $self->to_json(canonical=>1, pretty=>1);
$json =~ s/^/# /gm;
$json = "# MAPPING\n#\n${json}\n";
$rv .= $json;
}
$rv .= $self->SUPER::pro
) },
};
}
*TO_JSON = \&to_hashref;
sub to_json
{
my ($self, %opts) = (exists $_[1] and ref $_[1] eq 'HASH') ? ($_[0], %{ $_[1] }) : @_;
$opts{convert_blessed} = 1;
JSON::to_json($self, {%opts})
_json = sub { my $id = shift; ...; return $json; };
my $get_xml = sub { my $id = shift; ...; return $xml; };
my $get_txt = sub { my $id = shift; ...; return $txt; };
unAPI
json
=> wrAPI( $get_json => 'application/json' ),
xml => wrAPI( $get_xml => 'application/xml' ),
txt => wrAPI( $get_txt => 'text/plain', docs => 'http://example.com' );
The function C<
s resource in JSON
my $app2 = sub { ... }; # PSGI app that serves resource in XML
my $app3 = sub { ... }; # PSGI app that serves resource in plain text
unAPI
json => [ $app1 =
->{category}] $e->{message}"
}, sub {
open my $fh, '>>', 'log';
print {$fh} encode_json($_[1]) . "\n";
}],
});
$structured_log->log_event({ message => 'Starting web server' });
n $formatter->sprintf($_[1])
}, sub {
open my $fh, '>>', 'log';
print {$fh} encode_json($_[1]) . "\n";
}],
});
=head1 AUTHOR
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
=h
URLSafe;
use Crypt::OpenSSL::X509;
use Crypt::OpenSSL::RSA;
use Date::Parse;
use LWP::Simple;
use JSON;
=head1 NAME
GoogleIDToken::Validator - allows you to verify on server side Google Access Token
$signature = urlsafe_b64decode($signature);
$env = decode_json(urlsafe_b64decode($env));
$payload = decode_json(urlsafe_b64decode($payload));
if(!exists $self->{certs}-
he file($self->{certs_cache_file}): $!";
my $json_certs = '';
while(<$fh>) { $json_certs .= $_ }
if($json_certs) {
$self->parse_certs($json_certs);
} else {
$self->{certs} = undef;
ot edit
this file, but rather the original, inline with EntityModel::Definition::JSON
at lib/EntityModel/Definition/JSON.pm
(on the system that originally ran this).
If you do edit this file, and don'
to be removed, make
sure you change the first line.
=cut
=head1 NAME
EntityModel::Definition::JSON - definition support for L<EntityModel>
=head1 VERSION
version 0.102
=head1 SYNOPSIS
See L<En
to a file.
=head2 save_string
Return output as a scalar.
=head2 parse
Create and parse the L<JSON::XS> object.
=head1 INHERITED METHODS
=over 4
=item L<EntityModel::Definition>
L<add_entity_t
ccessor
accessors => {
map { $_ => $_ } qw(
dump_ast
dump_ast_json
dump_compiled
compile_only
)
}
;
sub new {
my $class = s
\$self->{dump_compiled},
'ast' => \$self->{dump_ast},
'ast-json' => \$self->{dump_ast_json},
'c' => \$self->{compile_only},
);
if (defined $eval)
**\n";
print "\n\n";
}
if ($self->dump_ast_json) {
require JSON::PP;
print "*** AST ***\n";
print JSON::PP->new->pretty(1)->encode(Perl6::PVIP->new->parse_strin
:jsonschema;
&usage if @ARGV < 2;
my $schema_file = shift;
my $app = App::jsonschema->new( schema_file => $schema_file );
$app->validate(@ARGV);
sub usage {
print STDERR "Usage: $0 schema.json
file1.json [file2.json ...]\n";
exit 1;
}
# ABSTRACT: Validate JSON files using JSON Schema
# PODNAME: jsonschema.pl
__END__
=pod
=encoding utf-8
=head1 NAME
jsonschema.pl - Validate JSON file
s using JSON Schema
=head1 VERSION
version 0.03
=head1 SYNOPSIS
jsonschema.pl schema.json file1.json [file2.json ...]
=head1 SEE ALSO
L<App::jsonschema>, L<JSON>, L<JSON::Schema>
=head1 AUTHOR
use strict;
use warnings;
package App::jsonschema;
{
$App::jsonschema::VERSION = '0.03';
}
use JSON::Schema;
use JSON qw/from_json/;
use autodie;
use Moo;
use feature qw/say/;
use Data::Dump qw/dump
/;
# ABSTRACT: Command-line utility to validate JSON using JSON Schema
has schema_file => (
is => 'rw',
required => 1,
isa => sub { die "Could not find file '$_[0]'!" unless -f $_[0] }
'lazy' );
has validator => ( is => 'lazy' );
sub _build_validator {
my $self = shift;
return JSON::Schema->new($self->schema);
}
sub _build_schema {
my $self = shift;
my $schema;
{
local $/
y $json = $self->ua->post(
'https://www.google.com/voice/inbox/deleteMessages' => form => {
messages => $self->id,
trash => 1,
_rnr_se => $self->rnr_se
}
)->res->json;
$@ = $json->{data}->{code} and return unless $json->{ok};
return $json->{ok};
}
sub download {
my $self = shift;
my ($from, $to) = @_;
my $res = $self->ua->get(
'https://www.google.c
8)');
# for translate
use LWP::UserAgent;
use HTTP::Headers;
use URI::Escape;
# for getToken
use JSON;
use Data::Dumper;
use HTTP::Request::Common qw(POST);
#http://stackoverflow.com/questions/39213
elf, $class;
return $self;
}
sub decodeJSON {
my $rawJSON = shift;
my $json = new JSON;
my $obj = $json->decode($rawJSON);
#print "The structure of obj: ".Dump
;
$content = $response->decoded_content;
my $accessToken = &decodeJSON($content);
$authToken = "Bearer" . " " . "$accessToken";
} else {
package Google::Voice;
use strict;
use warnings;
use Mojo::UserAgent;
use Mojo::JSON;
use IO::Socket::SSL 1.37;
use Google::Voice::Feed;
use Google::Voice::Call;
use Mojo::Base -base;
our $VERSIO
nd_sms {
my $self = shift;
my $c = $self->ua;
my ($phone, $content) = @_;
my $json = $c->post(
'https://www.google.com/voice/b/0/sms/send',
form => { id
_rnr_se => $self->rnr_se
}
)->res->json;
$@ = $json->{data}->{code} and return unless $json->{ok};
return $json->{ok};
}
for my $feed (
qw/ all starred spam trash
g/sinatraish/>.
=head1 FAQ
=over 4
=item Is Tiffany supports JSON?
Tiffany should not support JSON. Tiffany protocol can support JSON serialize.
But real web application needs more things like Con
f->ua(shift);
return $self;
}
sub cancel {
my $self = shift;
my ($from, $to) = @_;
my $json = $self->ua->post(
'https://www.google.com/voice/call/cancel/' => form => {
forwardingN
',
_rnr_se => $self->rnr_se
}
)->res->json;
$@ = $json->{data}->{code} and return unless $json->{ok};
return $json->{ok};
}
1;
=head1 NAME
Google::Voice::Call
=head1 DES
ned $_[0]) ? false :
(exists $bool_vals->{overload::StrVal($_[0])}) ? true : false;
}
sub TO_JSON { ${$_[0]} ? \1 : \0 }
sub isa {
my ($self, $stuff) = @_;
return UNIVERSAL::isa($self, $
ss {
model => { type => 'EntityModel::Model' },
};
use EntityModel;
use EntityModel::Definition::JSON;
use EntityModel::Definition::XML;
use Module::Load;
=head1 NAME
EntityModel::App - interface t
.json$/) {
$model->load_from(
JSON => { file => $file }
);
} elsif($file =~ /\.xml$/) {
$model->load_from(
XML => { file => $file }
);
} else {
die "Unknown extension, expected .json
elf->show_model;
},
'export' => sub {
my $self = shift;
my $def = EntityModel::Definition::JSON->new;
$def->model($self->model);
print $def->save(string => '');
},
'merge' => sub {
my
2
=head1 SYNOPSIS
use EntityModel;
# Define model
my $model = EntityModel->new->load_from(
JSON => { entity : [
{ name : 'article', field : [
{ name : 'idarticle', type : 'bigserial' },
s:
=over 4
=item * Type - must be a valid L<EntityModel::Definition> subclass, such as 'Perl', 'JSON' or 'XML'.
=item * Definition - dependent on the subclass, typically the filename or raw string
name => 'value', type => 'varchar' },
],
],
}
);
or the equivalent from JSON:
$model->load_from(
JSON => \q{
"name" : "kvstore",
"entity" : [
"name" : "object",
"primary"
N
version 0.0.3
=head1 SYNOPSIS
# Store a document as JSON in the database
package Document;
use Gideon driver => 'DBI';
use JSON;
...
has content => (
is => 'rw',
traits =>
[ 'Gideon::DBI::Column', 'Gideon::Inflate' ],
inflator => sub { decode_json $_[0] },
deflator => sub { encode_json $_[0] }
);
=head1 DESCRIPTION
It allows you to configurate an inflate and
2
=head1 SYNOPSIS
use EntityModel;
# Define model
my $model = EntityModel->new->load_from(
JSON => { entity : [
{ name : 'article', field : [
{ name : 'idarticle', type : 'bigserial' },
s:
=over 4
=item * Type - must be a valid L<EntityModel::Definition> subclass, such as 'Perl', 'JSON' or 'XML'.
=item * Definition - dependent on the subclass, typically the filename or raw string
name => 'value', type => 'varchar' },
],
],
}
);
or the equivalent from JSON:
$model->load_from(
JSON => \q{
"name" : "kvstore",
"entity" : [
"name" : "object",
"primary"
create tutorial.json
Add an entity:
entitymodel edit tutorial.json add entity name=something auto_primary=true
Add a field to an existing entity:
entitymodel edit tutorial.json entity something
utorial.json entity something add field name=unwanted type=text
entitymodel edit tutorial.json entity something remove field name=unwanted
Display the model:
entitymodel show tutorial.json
=head2
orial.json insert ...
=head2 Integrating with other systems
If you already have SQL schema as a starting point, you can import this and
generate a new model.
entitymodel import tutorial.json from
ent.
use strict;
use warnings;
use autodie;
use DBI qw(looks_like_number);
use DBD::SQLite;
use JSON::XS;
use Devel::Dwarn;
use Data::Dumper;
use Getopt::Long;
use Carp qw(carp croak confess);
use
y $opt_open,
) or exit 1;
$| = 1; #if $opt_debug;
my $run_size = 0;
my $total_size = 0;
my $j = JSON::XS->new->ascii->pretty(0);
my ($dbh, $node_ins_sth);
if ($opt_db) {
$dbh = DBI->connect("db
for (@outputs);
# output
# ...
if ($dbh) {
my $attr_json = $j->encode($x->{attr});
my $leaves_json = $j->encode($x->{leaves});
$node_ins_sth->execute(