Group
Extension

Matches 20

Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/lib/Dwarf/Plugin/JSON.pm ( view source; MetaCPAN )
package Dwarf::Plugin::JSON;
use Dwarf::Pragma;
use Dwarf::Util qw/encode_utf8 add_method/;
use JSON;

my %_ESCAPE = (
	'+' => '\\u002b', # do not eval as UTF-7
	'<' => '\\u003c', # do not eval as HTM
arf.json'} = JSON->new();
	$c->{'dwarf.json'}->pretty($conf->{pretty});
	$c->{'dwarf.json'}->convert_blessed($conf->{convert_blessed});
	$c->{'dwarf.json'}->ascii($conf->{ascii});
	$c->{'dwarf.json'}-
al});

	add_method($c, json => sub {
		my $self = shift;
		if (@_ == 1) {
			$self->{'dwarf.json'} = $_[0];
		}
		return $self->{'dwarf.json'};
	});

	add_method($c, decode_json => sub {
		my ($self, 
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/lib/Dwarf/Plugin/MouseX/Types/Common.pm ( view source; MetaCPAN )
warf::Util qw/add_method encode_utf8 decode_utf8/;
use Email::Valid;
use Email::Valid::Loose;
use JSON;
use Mouse;
use Mouse::Util::TypeConstraints;
use Regexp::Common qw/URI/;

sub init {
	my ($class
CreditcardSecurity
		=> as 'Str'
		=> where { $_ =~ /\A[0-9]{3,4}\z/ };

	subtype JSON
		=> as 'Str'
		=> where { _json($_) };

	subtype Base64JPEG
		=> as 'Str'
		=> where { _base64_type($_, 'jpeg') 
$s > 59 or $s < 0 ) {
		return 0;
	}

	return 1;
}

sub _json {
	my $value = $_;
	return 1 unless defined $value;
	my $data = eval { decode_json encode_utf8 $value };
	if ($@) {
		warn $@;
		warn $val
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/t/00_dwarf/validator/006_array.t ( view source; MetaCPAN )
pi/ping.json',
		'SERVER_NAME'       => 'perl.org',
		'HTTP_CONNECTION'   => 'TE, close',
		'REQUEST_METHOD'    => 'GET',
		'SCRIPT_URI'        => 'http://www.perl.org/dwarf/test/api/ping.json',
		'SC
RIPT_FILENAME'   => '/dwarf/test/api/ping.json',
		'SERVER_SOFTWARE'   => 'Apache/1.3.27 (Unix) ',
		'HTTP_TE'           => 'deflate,gzip;q=0.3',
		'QUERY_STRING'      => 'name[]=1&name[1]=2',
		'REMO
 => '/dwarf/test/api/ping.json',
		'REQUEST_URI'       => '/dwarf/test/api/ping.json',
		'GATEWAY_INTERFACE' => 'CGI/1.1',
		'SCRIPT_URL'        => '/dwarf/test/api/ping.json',
		'SERVER_ADDR'       =
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/lib/Dwarf/Util.pm ( view source; MetaCPAN )
rf::Pragma;
use parent qw(Exporter);
use Encode ();
use File::Basename ();
use File::Path ();
use JSON ();
use Scalar::Util qw(blessed refaddr);

our @EXPORT_OK = qw/
	add_method
	load_class
	installe
y
	filename
	read_file
	write_file
	get_suffix
	safe_join
	merge_hash
	random_string
	safe_decode_json
	encode_utf8
	decode_utf8
	encode_utf8_recursively
	decode_utf8_recursively
	apply_recursively
	d
and 36];
	}
	return $str;
}

# decode_json の undef 対策
sub safe_decode_json {
	my ($data) = @_;
	return undef unless defined $data;
	return JSON::decode_json($data);
}

# Encode-2.12 以下対策
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/lib/App/Test.pm ( view source; MetaCPAN )
Test;
use Dwarf::Pragma;
use parent 'Exporter';
use Data::Dumper;
use Encode qw/decode_utf8/;
use JSON;
use HTTP::Cookies;
use HTTP::Request::Common qw/GET HEAD PUT POST DELETE/;
use LWP::UserAgent;
u
0 || $res->code == 500) and $res->header('Content-Type') =~ /json/) {
		return $res unless $res->content;
		my $content = eval { decode_json($res->content) };
		if ($@) {
			warn $content;
		}
		$res-
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/t/00_dwarf/06_json_hijacking.t ( view source; MetaCPAN )
pi/ping.json',
		'SERVER_NAME'       => 'perl.org',
		'HTTP_CONNECTION'   => 'TE, close',
		'REQUEST_METHOD'    => 'GET',
		'SCRIPT_URI'        => 'http://www.perl.org/dwarf/test/api/ping.json',
		'SC
RIPT_FILENAME'   => '/dwarf/test/api/ping.json',
		'SERVER_SOFTWARE'   => 'Apache/1.3.27 (Unix) ',
		'HTTP_TE'           => 'deflate,gzip;q=0.3',
		'QUERY_STRING'      => '',
		'REMOTE_PORT'       => 
 => '/dwarf/test/api/ping.json',
		'REQUEST_URI'       => '/dwarf/test/api/ping.json',
		'GATEWAY_INTERFACE' => 'CGI/1.1',
		'SCRIPT_URL'        => '/dwarf/test/api/ping.json',
		'SERVER_ADDR'       =
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/lib/Dwarf/Module/APIBase.pm ( view source; MetaCPAN )
::Module';
use Dwarf::Validator;
use Dwarf::Validator::Constraint;
use Dwarf::Util qw/safe_decode_json encode_utf8/;
use Carp qw/croak/;
use HTTP::Date;

use Dwarf::Accessor {
	ro => [qw/autoflush_val
09/08/x-frame-options/
	
	$self->init_plugins($c);

	$self->type('application/json; charset=UTF-8');

	# defense from JSON hijacking
	my $user_agent = $c->req->user_agent || '';
	my $request_method = 
atus(403);
		$c->res->content_type('text/html; charset=utf-8');
		$c->finish("Your request may be JSON hijacking.\nIf you are not an attacker, please add 'X-Requested-With' header to each request.");
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/t/00_dwarf/02_dwarf.t ( view source; MetaCPAN )
 = Dwarf->new;
	my ($class, $ext) = $c->find_class('/api/ping.json');
	is_deeply([ $class, $ext ], [ 'Dwarf::Controller::Api::Ping', 'json' ], 'works fine');
};

subtest "find_method" => sub {
	my $c 
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/t/00_dwarf/03_pragma.t ( view source; MetaCPAN )
arf::Pragma;
use JSON;
use Test::More 0.88;

subtest "boolean" => sub {
	ok true;
	ok !false;
	ok (1 == 1);
	ok !(1 == 0);

	my $json = JSON->new->convert_blessed;
	my $encoded = $json->encode({ false
 => false, true => true });
	my $decoded = $json->decode($encoded);
	#is $encoded, '{"false":false,"true":true}';
};

done_testing();
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/t/00_dwarf/plugin/cors.t ( view source; MetaCPAN )
pi/ping.json',
		'SERVER_NAME'       => 'perl.org',
		'HTTP_CONNECTION'   => 'TE, close',
		'REQUEST_METHOD'    => 'POST',
		'SCRIPT_URI'        => 'http://www.perl.org/dwarf/test/api/ping.json',
		'S
CRIPT_FILENAME'   => '/dwarf/test/api/ping.json',
		'SERVER_SOFTWARE'   => 'Apache/1.3.27 (Unix) ',
		'HTTP_TE'           => 'deflate,gzip;q=0.3',
		'QUERY_STRING'      => 'hoge=a&name[]=hoge&name[1]=
 => '/dwarf/test/api/ping.json',
		'REQUEST_URI'       => '/dwarf/test/api/ping.json',
		'GATEWAY_INTERFACE' => 'CGI/1.1',
		'SCRIPT_URL'        => '/dwarf/test/api/ping.json',
		'SERVER_ADDR'       =
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/lib/App/Controller/ApiBase.pm ( view source; MetaCPAN )
eaders     => [qw/X-Requested-With Authorization Content-Type/],
			maxage      => 7200,
		},

		'JSON' => {
			pretty          => 1,
			convert_blessed => 1,
		},

		'XML::Simple' => {
			RootName   
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/lib/Dwarf/Module/SocialMedia/Rakuten.pm ( view source; MetaCPAN )
::Async;
use HTTP::Request::Common ();
use JSON;
use LWP::UserAgent;
use MIME::Base64 qw/decode_base64 encode_base64url/;
use Dwarf::Util qw/safe_decode_json encode_utf8/;
use Digest::SHA qw/hmac_sha2
 $self->ua->post($uri);

	my $content = eval { safe_decode_json(encode_utf8 $res->decoded_content) };
	if ($@) {
		warn "Couldn't decode JSON: $@";
		$content = $res->decoded_content;
	}

	return $con
t get access token.');
		return;
	}

	my $content = eval { decode_json $res->decoded_content };
	if ($@) {
		warn "Couldn't decode JSON: $@";
		$content = $res->decoded_content;
	}

	$self->_validate_
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/lib/Dwarf/Module/SocialMedia/Weibo.pm ( view source; MetaCPAN )
e Dwarf::HTTP::Async;
use DateTime;
use DateTime::Format::HTTP;
use HTTP::Request::Common ();
use JSON;
use LWP::UserAgent;

use Dwarf::Accessor qw/
	ua ua_async urls
	key secret
	access_token access_
ams);

	my $res = $self->ua->post($uri);
	$self->validate($res);

	my $json = $res->content;
	my $data = eval { decode_json($json) };
	if ($@) {
		warn $data;
	}

	$self->access_token($data->{access_t
ss_token} ||= $self->access_token;

	my $uri = URI->new($self->urls->{'api'} . '/' . $command . '.json');
	$uri->query_form(%{ $params }) if $method =~ /^(GET|DELETE)$/;

	my %data = %{ $params };

	i
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/lib/Dwarf/Module/SocialMedia/Facebook.pm ( view source; MetaCPAN )
e Dwarf::HTTP::Async;
use DateTime;
use DateTime::Format::HTTP;
use HTTP::Request::Common ();
use JSON;
use LWP::UserAgent;

use Dwarf::Accessor qw/
	ua ua_async urls
	key secret
	access_token access_
hod = uc $method;
	$params->{access_token} ||= $self->access_token;
	$params->{format}       ||= 'json';

	my $base_url = $command =~ /^method\//
			? $self->urls->{'old_api'}
			: $self->urls->{'api'
 validate {
	my ($self, $res) = @_;
	my $content = eval { decode_json($res->decoded_content) };
	if ($@) {
		warn "Couldn't decode JSON: $@";
		$content = $res->decoded_content;
	}

	if ($res->code !~
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/lib/Dwarf/Module/SocialMedia/Amazon.pm ( view source; MetaCPAN )
e Dwarf::HTTP::Async;
use DateTime;
use DateTime::Format::HTTP;
use HTTP::Request::Common ();
use JSON;
use LWP::UserAgent;
use Data::Dumper;

use Dwarf::Accessor qw/
	ua urls
	key secret
	access_toke
n_error->('Amazon OAuth Error: Could not get access token.');
		return;
	}

	my $decoded = decode_json $res->{_content};
	my $access_token = $decoded->{access_token};

	$self->access_token($access_tok
 validate {
	my ($self, $res) = @_;
	my $content = eval { decode_json($res->decoded_content) };
	if ($@) {
		warn "Couldn't decode JSON: $@";
		$content = $res->decoded_content;
	}

	# [todo] 
	# 	che
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/lib/Dwarf/Module/SocialMedia/Mixi.pm ( view source; MetaCPAN )
ync;
use Dwarf::Util qw/encode_utf8 decode_utf8 shuffle_array/;
use HTTP::Request::Common ();
use JSON;
use LWP::UserAgent;

use Dwarf::Accessor qw/
	ua ua_async urls
	key secret
	access_token refresh
e, $text) = @_;
	
	my $json = encode_json {
		title      => $title,
		body       => $text,
		recipients => [$id]
	};

	$self->call('messages/@me/@self/@outbox', 'POST', {}, $json);
}

sub is_following
 $self->access_token);
		if (defined $content) {
			push @p, (
				'Content-Type' => 'application/json',
				'Content'      => $content
			);
		}
	}

	no strict 'refs';
	my $req = &{"HTTP::Request::Co
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/lib/Dwarf/Validator/Constraint/Default.pm ( view source; MetaCPAN )
l::Valid::Loose;
use Dwarf::Util qw/encode_utf8 decode_utf8/;
use Image::Info qw/image_type/;
use JSON;
use MIME::Base64 qw(decode_base64 decoded_base64_length);
use Scalar::Util qw/looks_like_number/
ref $callback ne 'CODE';

	$callback->($_);
};

rule JSON => sub {
	my $value = $_;
	return 1 unless defined $value;
	my $data = eval { decode_json encode_utf8 $value };
	if ($@) {
		warn $@;
		warn $
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/lib/Dwarf/Module/SocialMedia/Line.pm ( view source; MetaCPAN )
e Dwarf::HTTP::Async;
use DateTime;
use DateTime::Format::HTTP;
use HTTP::Request::Common ();
use JSON;
use LWP::UserAgent;
use Data::Dumper;

use Dwarf::Accessor qw/
	ua urls
	key secret
	access_toke
>on_error->('Line OAuth Error: Could not get access token.');
		return;
	}

	my $decoded = decode_json $res->{_content};
	my $access_token = $decoded->{access_token};

	$self->access_token($access_tok
 validate {
	my ($self, $res) = @_;
	my $content = eval { decode_json($res->decoded_content) };
	if ($@) {
		warn "Couldn't decode JSON: $@";
		$content = $res->decoded_content;
	}

	# [todo] 
	# 	che
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/lib/Dwarf/Module/SocialMedia/Twitter.pm ( view source; MetaCPAN )
 Digest::SHA qw//;
use Encode qw/encode_utf8/;
use HTTP::Request::Common;
use HTTP::Response;
use JSON;
use LWP::UserAgent;
use Net::OAuth;

use Dwarf::Accessor qw/
	ua ua_async urls
	key secret
	requ
{
	my ($self, $src, $message) = @_;

	my $url = $self->urls->{api} . '/statuses/update_with_media.json';

	my $oauth = Net::OAuth->request('protected resource')->new(
		version          => '1.0',
		re
auth_request(
		'protected resource',
		request_url    => $self->urls->{api} . '/' . $command . '.json',
		request_method => $method,
		extra_params   => $params,
		token          => $self->access_tok
Cmd-Dwarf ( S/SE/SEAGIRL/Cmd-Dwarf-1.83.tar.gz, SEAGIRL, 2019; MetaCPAN )
Cmd-Dwarf/share/app/t/00_dwarf/05_request.t ( view source; MetaCPAN )
pi/ping.json',
		'SERVER_NAME'       => 'perl.org',
		'HTTP_CONNECTION'   => 'TE, close',
		'REQUEST_METHOD'    => 'GET',
		'SCRIPT_URI'        => 'http://www.perl.org/dwarf/test/api/ping.json',
		'SC
RIPT_FILENAME'   => '/dwarf/test/api/ping.json',
		'SERVER_SOFTWARE'   => 'Apache/1.3.27 (Unix) ',
		'HTTP_TE'           => 'deflate,gzip;q=0.3',
		'QUERY_STRING'      => 'hoge=あいうえお&name[]=
 => '/dwarf/test/api/ping.json',
		'REQUEST_URI'       => '/dwarf/test/api/ping.json',
		'GATEWAY_INTERFACE' => 'CGI/1.1',
		'SCRIPT_URL'        => '/dwarf/test/api/ping.json',
		'SERVER_ADDR'       =

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.