ss;
for(qw(request response controller action format params
session render render_json render_xml redirect_to)) {
*{"$caller\::$_"} = *{"$_"};
}
for (@Railsish::Contro
utf8($output));
}
use JSON -convert_blessed_universally;
sub render_json {
my %variables = @_;
my $json = JSON->new;
$json->allow_blessed(1);
my $out = $json->encode(\%variables);
$response->headers->header('Content-Type' => 'text/x-json');
$response->body( Encode::encode_utf8($out) );
}
use XML::Simple;
sub render_xml {
# still not write testing
my %variable
rsion; our $VERSION = $Parley::VERSION;
use base 'Catalyst::Controller';
use Image::Magick;
use JSON;
use Image::Size qw( html_imgsize imgsize );
use Parley::App::Error qw( :methods );
# ~~~~~~~~~
my ($self, $c) = @_;
my ($return_data, $json);
my $fieldname = $c->request->param('fieldname');
$c->response->content_type('text/json');
$return_data->{old_value} = $c->request-
return_data->{updated} = 0;
$json = to_json($return_data);
$c->response->body( $json );
$c->log->info( $json );
return;
};
o load your application's configuration file in any format supported by Config::Any (Apache-like, JSON, YAML, XML, Windows INI, etc).
$c->load_config('somefile.yml');
Then just access its items
SCRIPTION
C<Data::Transform::Type::DBIx> is used to transform L<DBIx::Class::Row>
instances into JSON-able structures, using C<get_inflated_columns> to get make
a hashref from the object's keys (colu
es, contact the author.
=head1 AUTHOR
Adam Kennedy E<lt>adamk@cpan.orgE<gt>
=head1 SEE ALSO
L<JSON>, L<http://ali.as/>
=head1 COPYRIGHT
Copyright 2003 - 2009 Adam Kennedy.
This program is free
y blessed($schema);
say ref($schema);
die("schema must be a JSON::Validator") unless (blessed($schema) && $schema->isa('JSON::Validator'));
}
method applies_to (%params) {
my $node
SCRIPTION
C<Data::Transform::Type::DBIx> is used to transform L<DBIx::Class::Row>
instances into JSON-able structures, using C<get_inflated_columns> to get make
a hashref from the object's keys (colu
package WWW::Omegle;
use 5.006000;
use strict;
use warnings;
use Carp qw/croak/;
use JSON;
use base qw/WWW::Mechanize/;
use HTTP::Async;
use HTTP::Request;
use HTTP::Request::Common;
our $VERSION
ra;
$self->{om_callbacks}->{$action} = $cb;
}
# process a HTTP::Response from /events. parse JSON and dispatch to callbacks
sub handle_event {
my ($self, $res) = @_;
unless ($res->is_suc
# not JSON array of events
$self->callback(error => "Got invalid JSON: " . $res->content);
return;
}
}
my $json = new JSON;
my $events = $json->decod
n ($format) {
when ("widget") { render_widget() }
when ("json") { render_json() }
}
}
sub render_json {
}
sub render_widget
1;
__END__
=head1 NAME
CPAN::MirrorStatus -
n.nctu.edu.tw"); #=> which mirror status do you want to know
$q->query;
$q->render("json"); #=> output json
$q->render("widget"); #=> output javascript widget
=head1 DESCRIPTION
=head1 AUTH
package Chef::Recipe;
use warnings;
use strict;
use Moose;
use JSON;
use Data::Dumper;
has 'resource_collection' =>
( is => 'rw', isa => 'ArrayRef', default => sub { [] } );
sub add_resource {
}
sub prepare_json {
my $self = shift;
my @resource_collection;
foreach my $resource ( @{ $self->resource_collection } ) {
push( @resource_collection, $resource->prepare_json );
}
retur
package Chef;
use Chef::Recipe;
use Chef::Resource;
use Data::Dumper;
use JSON::Any qw(XS JSON DWIW);
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(resource node);
use warnings;
use strict
{
my $data;
while ( my $line = <STDIN> ) {
$data = $data . $line;
}
$node_data = JSON::Any->jsonToObj($data);
1;
}
=head2 resource
Create a new Chef Resource. Valid resources are list
resource);
}
sub send_to_chef {
print JSON::Any->objToJson(
{
node => $node_data,
resource_collection => $recipe->prepare_json
}
);
}
sub END {
send_to_chef;
y $bit (@parts) {
$class = $class . '::' . ucfirst($bit);
}
return $class;
}
sub prepare_json {
my $self = shift;
my $cr = {};
$cr->{'instance_vars'} = { '@name' => $self->name, };
options } ) ) {
$cr->{'instance_vars'}->{ "@" . $key } = $self->options->{$key};
}
$cr->{'json_class'} = $self->ruby_class;
return $cr;
}
sub AUTOLOAD {
my $self = shift;
my $attr = $Ch
:Basename qw(dirname);
sub new {
my $pkg = shift;
my %p = @_;
$p{metafile} ||= 'META.json';
if (my $keywords = delete $p{keywords} || delete $p{tags}) {
if ($p{meta_merge}) {
ake_tarball($dist_dir);
$self->delete_filetree($dist_dir);
# $self->add_to_cleanup('META.json');
# $self->add_to_cleanup('*.gz');
}
sub ACTION_manifest {
my $self = shift;
$self->
re('JSON_support')) {
require JSON;
$self->prepare_metadata( my $node = {} );
open my $meta, '>', $metafile or die "Cannot open '$metafile': $!\n";
print $meta JSON->ne
set {
my $self = shift;
my $query = shift;
my $cgi_query;
my $count = 0;
my $json;
if (ref($query) ne 'HASH' && $query->can("param")) {
# Make a copy
$cgi_quer
>{json} ) {
my $url_decoded_json = uri_unescape($query->{params}->{json});
if ($self->{json}->can("decode")) {
# Modern-ish 2.x JSON API
$json =
$self->{json}->decode( $url_decoded_json );
} elsif ($self->{json}->can("jsonToObj")) {
# Olde Version 1.x JSON API
$json = $self->{json}->jsonToObj( $url_
use SOAPjr::request;
use SOAPjr::response;
=head1 NAME
SOAPjr - SOAP without the bloat and JR (JSON-RPC) with proper error handling and file uploads
=head1 VERSION
Version 1.1.4
=cut
our $VERSI
d documentation then replace t/pod-coverage.t.
Also need to create Server and Client modules ala JSON::RPC and more detailed example scripts.
=head1 ACKNOWLEDGEMENTS
See L<http://SOAPjr.org/specs.h
::Plugin::Wikipedia;
use strict;
use warnings;
use URI;
use URI::QueryParam;
use URI::Escape;
use JSON::Syck;
use Jcode;
use Encode::JavaScript::UCS;
use base qw(App::SocialSKK::Plugin);
sub get_cand
=> $text);
my $res = $self->ua->get($uri);
if ($res->is_success) {
my $array = JSON::Syck::Load($res->content);
map {
my $text = Encode::JavaScript::UCS::decode(
Exporter;
use base "JSON::PP";
use overload;
use Carp ();
use B ();
use Class::C3;
$JavaScript::Dumper::VERSION = '0.011';
@JavaScript::Dumper::EXPORT = qw(js_dumper);
my $JSON; # cache
sub js_d
umper ($) { # encode
($JSON ||= __PACKAGE__->new)->encode(@_);
}
sub value_to_json {
my ($self, $value) = @_;
my $type = ref($value);
if (!defined $value) {
return "null";
} elsif($type eq
lean" => true, "call": function}]";
=head1 DESCRIPTION
This module uses L<JSON::PP> as base and overrides C<value_to_json> to accept SCALAR-refs to be returned without quotes.
=head1 FUNCTIONS
=o
r response::add_message()";
return 0;
}
}
sub output {
my $self = shift;
my $json;
my $body = $self->get("BODY");
if ($self->get("HEAD")->{errors}) {
$self->set({
elf->{json}->can("encode")) {
# Modern-ish 2.x JSON API
$json = $self->{json}->encode( { HEAD => $self->get("HEAD"), BODY => $body } );
} elsif ($self->{json}->can("objToJson")) {
Version 1.x JSON API
$json = $self->{json}->objToJson( { HEAD => $self->get("HEAD"), BODY => $body } );
} else {
# TODO: handle unknown JSON API
}
return $json;
}
sub sen
ut
our $VERSION = "1.0.1";
=head1 SYNOPSIS
See perldoc SOAPjr for more info.
=cut
use JSON;
$JSON::UnMapping = 1;
sub new {
my $self = {};
my $class = shift;
bless $self, $class
=> 1,
BODY => 1,
HEAD => 1,
OPTIONS => 1
};
$self->{json} = JSON->new();
return $self->_init(@_);
}
sub _init {
my $self = shift;
return $self;
}
strict;
use warnings;
use vars qw($VERSION);
use LWP::UserAgent ();
use HTTP::Headers ();
use JSON ();
$VERSION = '0.07';
sub new {
my $class = shift;
my $appid = shift;
my %options = @_;
parameters
$self->{ua} = LWP::UserAgent->new;
$self->{appid} = $appid;
$self->{format} = 'json';
foreach (keys %options) {
$self->{$_} = $options{$_};
}
bless($self, $class);
}
sub u
esp, \@result);
}
if (wantarray) {
return @result;
} else {
return $result[0];
}
}
sub json_parser {
my $self = shift;
my $resp = shift;
my $result = shift;
my $content = $resp->c