package JSON::Schema::Helper;
###
# JSONSchema Validator - Validates JavaScript objects using JSON Schemas
# (http://www.json.com/json-schema-proposal/)
#
# Copyright (c) 2007 Kris Zyp SitePen (www
.sitepen.com)
# Licensed under the MIT (MIT-LICENSE.txt) license.
#To use the validator call JSONSchema.validate with an instance object and an optional schema object.
#If a schema is provided, it wil
t FALSE => !1;
use constant TRUE => !!1;
no autovivification;
use JSON qw[-convert_blessed_universally];
use JSON::Hyper;
use JSON::Schema::Null;
use POSIX qw[modf];
use Scalar::Util qw[blessed];
us
use 5.008;
use strict;
use warnings;
{
package Syntax::Highlight::JSON2;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.003';
use MooX::Struct -retain, -rw,
Feature =
intf "<span class=\"json_%s\">%s</span>", lc $_[0]->TYPE, encode_entities($_[0]->spelling)
};
*{Whitespace . "::TO_HTML"} = sub { $_[0]->spelling };
}
our %STYLE = (
json_brace => 'col
0;font-weight:bold',
json_bracket => 'color:#990000;font-weight:bold',
json_punctuation => 'color:#990000;font-weight:bold',
json_string => 'color:#cc00cc',
json_keyword => 'color
ge JSON::GRDDL;
use Carp;
use JSON;
use JSON::T;
use LWP::UserAgent;
use Object::AUTHORITY;
use RDF::Trine;
use Scalar::Util qw[blessed];
BEGIN {
$JSON::GRDDL::AUTHORITY = 'cpan:TOBYINK';
$JSON::G
ta
{
my ($self, $document, $uri, %options) = @_;
unless (ref $document)
{
$document = from_json("$document");
}
$options{'model'} ||= RDF::Trine::Model->temporary_model;
my $T = $self->d
RDF/JSON.
$options{'model'}->add_hashref($document);
return $options{'model'};
}
elsif (ref $document eq 'HASH'
and $document->{'$schema'}->{'$ref'} eq 'http://soapjr.org/schemas/RDF_JSON')
package Scalar::Accessors::LikeHash::JSON;
use 5.008;
use strict;
use warnings;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.002';
use JSON;
use Role::Tiny::With;
with 'Scalar::Accessors::
= JSON::->new)->decode($$ref);
}
sub _from_hash
{
my ($ref, $hash) = @_;
$$ref = ($j ||= JSON::->new)->encode($hash);
}
1;
__END__
=head1 NAME
Scalar::Accessors::LikeHash::JSON - access a JSON
calar string in a hash-like manner
=head1 SYNOPSIS
my $object = Scalar::Accessors::LikeHash::JSON->new;
$object->store(some_key => 42) unless $object->exists('some_key');
$object->fetch
er::Session::Memcached::JSON;
our $VERSION = '0.005'; # VERSION
# ABSTRACT: Session store in memcached with JSON serialization
use base 'Dancer::Session::Abstract';
use JSON;
use Cache::Memcached;
ode qw(encode_utf8 decode_utf8);
use Dancer::Config qw(setting);
use Dancer::Session::Memcached::JSON::Signature qw(sign unsign);
my $MEMCACHED;
my $secret;
sub init {
my ($class) = @_;
my
g('session_cookie_path') // '/',
httpOnly => setting('session_is_http_only') // JSON::true,
expires => setting('session_expires'),
originalMaxAge => un
use strict;
use warnings;
package Dancer::Session::Memcached::JSON::Signature;
# Adapted from https://github.com/visionmedia/node-cookie-signature
use Digest::SHA qw(hmac_sha256_base64 sha1_hex);
us
1_hex($mac) eq sha1_hex("s:$val");
}
1;
__END__
=pod
=head1 NAME
Dancer::Session::Memcached::JSON::Signature
=head1 VERSION
version 0.005
=head1 AUTHOR
Forest Belton <forest@homolo.gy>
=head
package JSON::Schema;
use 5.010;
use strict;
use Carp;
use HTTP::Link::Parser qw[parse_links_to_rdfjson relationship_uri];
use JSON;
use JSON::Hyper;
use JSON::Schema::Error;
use JSON::Schema::Helpe
ma = from_json($schema) unless ref $schema;
$options{format} //= {};
return bless { %options, schema => $schema }, $class;
}
sub detect
{
my ($class, $source) = @_;
my $hyper = JSON::Hyper->n
l);
if ($source->isa('HTTP::Response'))
{
$url = $source->request->uri;
$object = from_json($source->decoded_content);
}
else
{
$url = "$source";
($source, my $frag) = split /\#/, $s
package MojoX::JSON::RPC::Service::AutoRegister;
use Mojo::Base 'MojoX::JSON::RPC::Service';
our $VERSION = 0.001;
=head1 NAME
MojoX::JSON::RPC::Service::AutoRegister - Base class for RPC Services
_self'=1> options by default.
For more information on how services work, have a look at
L<MojoX::JSON::RPC::Service>.
Every function that starts with C<rpc_> it's automatically registered as an
rpc
functions to being automatically registered.
=head1 METHODS
Inherits all methods from L<MojoX::JSON::RPC::Service> and adds the following new ones:
=head2 register_rpc
witouth arguments, register
package JSON::Schema::Result;
use 5.010;
use strict;
use overload bool => \&valid;
use JSON::Schema::Error;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.016';
sub new
{
my ($class, $resul
{ JSON::Schema::Error->new($_); } @{$self->{'errors'}};
}
1;
__END__
=head1 NAME
JSON::Schema::Result - the result of checking an instance against a schema
=head1 SYNOPSIS
my $validator = JSON:
:Schema->new($schema);
my $json = from_json( ... );
my $result = $validator->validate($json);
if ($result)
{
print "Valid!\n";
}
else
{
print "Errors\n";
print " - $_\n" foreac
package JSON::Schema::Null;
use 5.010;
use strict;
use overload '""' => sub { return '' };
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.016';
sub new
{
my ($class) = @_;
my $x = '';
retu
rn bless \$x, $class;
}
sub TO_JSON
{
return undef;
}
1;
__END__
=head1 NAME
JSON::Schema::Null - represents JSON's null value
=head1 SEE ALSO
L<JSON::Schema>.
=head1 AUTHOR
Toby Inkster E<l
package Acme::MooseX::JSON;
use 5.008;
use strict;
use warnings;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.002';
use Moose 2.00 ();
use Moose::Exporter;
use Moose::Util::MetaRole;
use Sc
alar::Accessors::LikeHash::JSON ();
my $ACCESSORS = "Scalar::Accessors::LikeHash::JSON";
BEGIN {
package Acme::MooseX::JSON::Trait::Class;
use Moose::Role;
our $AUTHORITY = 'cpan:TOBYINK';
our $
VERSION = '0.002';
};
BEGIN {
package Acme::MooseX::JSON::Trait::Instance;
use Moose::Role;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.002';
override create_instance => sub {
my
package Data::Phrasebook::Loader::JSON;
use strict;
use warnings FATAL => 'all';
our $VERSION = '0.02';
#--------------------------------------------------------------------------
use base qw( Dat
File::Slurp;
use JSON::XS;
#--------------------------------------------------------------------------
=head1 NAME
Data::Phrasebook::Loader::JSON - Absract your phrases with JSON.
=head1 SYNOPSIS
my $q = Data::Phrasebook->new(
class => 'Fnerk',
loader => 'JSON',
file => 'phrases.json',
);
$q->delimiters( qr{ \[% \s* (\w+) \s* %\] }x );
my $phrase = $
package JSON::RPC::Lite;
use strict;
use warnings;
use version; our $VERSION = version->declare("v1.0.0");
use JSON::RPC::Spec;
use Plack::Request;
sub import {
my $pkg = caller(0);
my $
rpc = JSON::RPC::Spec->new;
my $method = sub ($$) {
$rpc->register(@_);
};
no strict 'refs';
*{"${pkg}::method"} = $method;
*{"${pkg}::as_psgi_app"} = sub {
my $body = $rpc->parse($req->content);
my $header = ['Content-Type' => 'application/json'];
if (length $body) {
return [200, $header, [$body]];
}
package JSON::Decode::Marpa;
our $DATE = '2014-08-27'; # DATE
our $VERSION = '0.02'; # VERSION
use 5.010001;
use strict;
use warnings;
use MarpaX::Simple qw(gen_parser);
require Exporter;
our @ISA
qw(Exporter);
our @EXPORT_OK = qw(from_json);
my $parser = gen_parser(
grammar => <<'EOF',
:default ::= action => do_array
:start ::= json
json ::= object action => do_first
tring lexeme> ~ quote <string contents> quote
# This cheats -- it recognizers a superset of legal JSON strings.
# The bad ones can sorted out later, as desired
quote ~ ["]
<string contents> ~ <string
org/licenses/>.
package App::MtAws::Glacier::Inventory::JSON;
our $VERSION = '1.120';
use strict;
use warnings;
use utf8;
use Carp;
use JSON::XS 1.00;
use App::MtAws::Glacier::Inventory ();
use b
elf = { rawdata => \$_[0] };
bless $self, $class;
$self;
}
sub _parse
{
my ($self) = @_;
$self->{data} = JSON::XS->new->allow_nonref->utf8->decode(${ delete $self->{rawdata} || confess });
}
1;
package JSON::WebEncryption;
use strict;
use parent 'Exporter';
our $VERSION = '0.05';
use Carp qw(croak);
use Crypt::CBC;
use Crypt::OpenSSL::RSA;
use JSON qw(decode_json encode_json);
use Digest
->encode(encode_json($hash));
}
# -----------------------------------------------------------------------------
sub decode_to_hash {
my ($self, $jwe) = @_;
return decode_json($self->decode(
nc,
%$extra_headers,
};
my @segment;
push @segment, encode_base64url( encode_json($header) );
push @segment, encode_base64url( $encrypted_key );
push @segment, encode_base
package JBD::JSON::Transformers;
# ABSTRACT: JSON parser token transformers
our $VERSION = '0.04'; # VERSION
# JSON parser token transformers.
# @author Joel Dalley
# @version 2014/Mar/22
use JBD::C
ore::Exporter ':omni';
use JBD::Parser::DSL;
use JBD::JSON::Lexers;
# @param arrayref Array of JBD::Parser::Tokens.
# @return arrayref Same array, minus Nothing-type tokens.
sub remove_novalue {
::Parser::Tokens.
# @return arrayref A single JsonString-typed token array.
sub reduce_JsonString {
my $tokens = remove_novalue shift;
[token 'JsonString', join '', map $_->value, @$tokens];
}
package JBD::JSON::Lexers;
# ABSTRACT: JSON lexers
our $VERSION = '0.04'; # VERSION
# JSON Lexers.
# @author Joel Dalley
# @version 2014/Mar/22
use JBD::Core::Exporter;
use JBD::Parser::DSL;
our @E
XPORT = qw(
JsonSpace JsonNum JsonNull JsonBool
JsonSquareBracket JsonCurlyBrace
JsonColon JsonComma JsonQuote JsonStringChar
JsonEscapeSeq UnicodeEscapeSeq JsonEscapeChar
);
|| hex "0x$1" < 0
|| hex "0x$1" > 0x001F; $1;
}, 'UnicodeEscapeSeq';
}
sub JsonEscapeChar {
bless sub {
my $chars = shift;
return unless length $chars;
ckage JBD::JSON::Grammar;
# ABSTRACT: a JSON grammar
our $VERSION = '0.04'; # VERSION
# A JSON grammar.
# @author Joel Dalley
# @version 2014/Mar/18
use JBD::Core::Exporter;
use JBD::JSON::Transfor
'reduce_JsonString';
use JBD::JSON::Lexers;
use JBD::Parser::DSL;
our @EXPORT = qw(
init json_space
json_member_list json_element_list
json_bool_literal json_null_literal
json_escape_
char json_escape_seq
json_string_char star_string_char
json_member json_object json_string
json_array json_value json_text
);
#///////////////////////////////////////////////////////
package JBD::JSON;
# ABSTRACT: provides JSON parsing subs
our $VERSION = '0.04'; # VERSION
# JSON parsing subs.
# @author Joel Dalley
# @version 2014/Mar/22
use JBD::Core::Exporter ':omni';
use JBD
ser::DSL;
use JBD::JSON::Lexers;
use JBD::JSON::Grammar;
use JBD::JSON::Transformers 'remove_novalue';
# @param string $parser A JBD::Parser sub name.
# @param scalar/ref $text JSON text.
# @return a
t json_array => \&remove_novalue,
json_object => \&remove_novalue;
my $st = parser_state tokens $text, [
JsonNum, JsonQuote, JsonComma,
JsonColon, JsonC