ugin::Cache::VERSION = '0.0.3';
}
use Moose;
use JSON;
use Gideon::Registry;
#ABSTRACT: Cache Plugin
extends 'Gideon::Plugin';
my $serializer = JSON->new->utf8->canonical;
sub find_one {
my (
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
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
C_mqNvxq`@
print $eline->{levels}; # POP
# in Javascript, assuming eline was encoded as JSON:
# ... load GMap2 ...
var opts = {
points: eline.points,
levels: eline.levels,
nu
num_levels => int($num_levels),
zoom_factor => int($zoom_factor),
};
You can then use the L<JSON> modules (or XML, or whatever) to pass the encoded
values to your Javascript application for use
/GoogleMaps/EncodePolyline/PolylineEncoderClass.html>
(JavaScript implementation),
L<http://www.usnaviguide.com/google-encode.htm> (similar implementation in perl),
L<Geo::Google>,
L<JSON::Any>
=cut
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 $/
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"
/_/sg;
$incomingText =~ s/^\s+//;
return $incomingText;
}
=head2 safeJSON
Replace any thing harmful to an JSON node that could cause it to fail. It will escape stuff like quotes and such.
This "Can not" be in json';
my $safeSillyNode = $fws->safeJSON( $sillyNode );
print 'Safe JSON: '.$sillyNode;
=cut
sub safeJSON {
my ( $self, $incomingText ) = @_;
$incomingText =~
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"
use JSON::XS;
use HTML::Entities qw(encode_entities);
use Getopt::Long;
use Devel::Dwarn;
use Devel::SizeMe::Graph;
use DBI;
my $dbh;
my %node_queue;
my %node_cache;
my $db_modtime;
my $j = JSON::XS
html<span class="divider">$divider</span></li>}
} @{$response{name_path}};
$self->render(json => \%response);
};
sub _set_node_queue {
my $nodes = shift;
++$node_queue{$_} for @$node
)); # numify
$node->{leaves} = $j->decode(delete $node->{leaves_json});
$node->{attr} = $j->decode(delete $node->{attr_json});
return $node;
}
sub _fetch_node_tree {
my ($id, $depth
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
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
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
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(
->{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
ict;
use warnings;
use Moo;
use Types::Standard qw(ArrayRef);
use Path::Tiny;
use JSON;
use overload '""' => \&json;
our $VERSION = 0.16;
has objects => (
is => 'rw',
isa => Array
tropo => \@objects,
};
return $data;
}
sub json {
my ($self) = @_;
my $data = $self->perl;
my $string = JSON->new->encode( $data );
return $string;
}
sub ad
to => $clients_phone_number,
);
$tropo->say( 'hello ' . $client_name );
$tropo->json;
Creates this JSON output:
{
"tropo":[
{
"call": {
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 {
000;
use strict;
use warnings;
use HTTP::Request;
use LWP::UserAgent;
use URI::Escape;
use JSON qw(encode_json);
our $VERSION = '0.05';
our $EMPTY = q{};
our $SL = q{/};
our $AM = q{&};
our $EQ = q{=
>{'version'} || '3';
$package->{'type'} = $params->{'type'} || 'json';
$package->{'uri'} = $params->{'uri'} || 'http://api.themoviedb.org';
y $params = shift;
my $url = $params->{'url'};
my $method = $params->{'method'};
my $json = $params->{'json'} || $EMPTY;
my $ua = LWP::UserAgent->new;
$ua->agent("WWW::TheMovieDB/". $VERSION
=> Str,
required => 1,
);
has from => (
is => 'ro',
isa => Str,
exclude_from_json => 1,
);
has ['network', 'channel'] => (
is => 'ro',
isa => Str,
);
has 'answer_on_med