ost stuff works including:
* Loading and dumping of basic types
* Block and flow styles (JSON Loading)
* Blessed hashes arrays and scalars
* References
* Tags
* Detailed error
:Log4perl::Layout::PatternLayout/;
use Carp;
use Scalar::Util qw/looks_like_number blessed/;
use JSON::Any;
=head1 METHODS
=head2 $class->new
Returns: a FirePHP compatible L<Log::Log4perl::Layout
my $self = $this->SUPER::new( @_ );
$self->{info_needed}{$_} = 1 for qw/F L M l/;
$self->{json} = JSON::Any->new;
return $self;
}
# unfortunately this had to be lifted almost verbatim from
# Lo
h = (
Type => $type,
File => $info{F},
Line => $info{L},
);
return $self->{json}->objToJson(
[ \%info_hash, $rendered_message ]
);
}
1;
__END__
=head1 SEE ALSO
L<http://ww
Carp;
use Scalar::Util qw/looks_like_number blessed/;
use JSON::Any;
__PACKAGE__->mk_accessors(
qw/http_headers message_index stash json group_stack/
);
=head1 GENERAL METHODS
=head2 $class->n
tp_headers,
message_index => 0,
group_stack => [],
stash => {},
json => JSON::Any->new(),
});
}
=head2 $self->finalize
Add the needed protocol headers and meta
x;
$http->header(
'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/' .
'Protocol/JsonStream/0.2',
'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/' .
'Wildfire/Plugin/Fire
package WebService::RequestAPI::AbstractRequestAPI;
use strict;
use utf8;
use JSON;
use XML::Simple;
use base qw(Class::Data::Inheritable Class::Accessor);
__PACKAGE__->mk_accessors(qw/result cache_id
my $self = shift;
my %args = @_;
$self->cache_manager($args{'cache_manager'});
}
sub parse_json{
my $self = shift;
if($self->cache_manager){
if($self->cache_manager->is_cached($self->cach
>cache_id);
}
my $result = decode_json($self->result);
$self->cache_manager->store_cache($self->cache_id,$result);
return $result;
}
return decode_json($self->result);
}
sub parse_xml{
m
Plugin::VMethods );
use Carp;
use Data::Dump;
use JSON::XS;
our $VERSION = '0.003';
our @SCALAR_OPS = our @LIST_OPS = our @HASH_OPS
= qw( as_json dump_stderr dump_data );
push( @SCALAR_OPS, qw(
t
=head1 SYNOPSIS
[% USE Handy;
mything.dump_data;
mything.dump_stderr;
mything.as_json;
%]
=head1 DESCRIPTION
Handy virtual methods I always use in my Template Toolkit files,
esp
ckage object
my $JSON = JSON::XS->new;
$JSON->convert_blessed(1);
$JSON->allow_blessed(1);
# mysql serial fields are rendered with Math::BigInt objects in RDBO.
# monkeypatch per JSON::XS docs
sub Ma
'endpoint'=>'http://rpc.clip.livedoor.com/');
__PACKAGE__->base_url('http://api.clip.livedoor.com/json/');
sub count{
my $self = shift;
my @urls = @_;
return $self->request_api_xmlrpc()->request('
package CouchDB::ExternalProcess;
use strict;
use warnings;
use Attribute::Handlers;
use JSON::Any;
BEGIN {
use Exporter ();
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
($class, %parameters) = @_;
my $self = bless ({}, ref ($class) || $class);
$self->jsonParser(JSON::Any->new);
return $self;
}
=head2 run
Run the action, read lines from STDIN and pro
(my $reqJson = <$in_fh>) {
my $output = $self->_process($reqJson);
print $out_fh $output . $/;
}
close($in_fh);
close($out_fh);
$self->_destroy;
}
=head2 jsonParser
package WebService::RequestAPI::XMLRPCRequestAPI;
use strict;
use XMLRPC::Lite;
use JSON;
use utf8;
use base qw(WebService::RequestAPI::AbstractRequestAPI);
sub _request{
my $self = shift;
my $met
ackage GPS::Garmin::Connect;
use warnings;
use strict;
use LWP::UserAgent;
use HTML::Form;
use JSON;
use Error;
=head1 NAME
GPS::Garmin::Connect - Allows simple fetching of
activities from http
my $connect = GPS::Garmin::Connect->new();
my $json = $connect->fetchdata( $username, $password );
my $activities = $connect->parse( $json );
foreach my $activity (@$activities) {
$username, $password );
Logins into connect.garmin.com and fetches all activities and returns
a JSON string which can be parsed using L<parse>.
=cut
sub fetchdata {
my ($pkg, $username, $passwor
pe {
my $value=shift;
$value->escape(1);
return $value;
}
#Not for JSON output of objects, I need to write an JSON-Addon for that.
my %jsescape = (
"\n" => "\\n",
"\r" => "\\r",
"\t
hem.
=head2 escapejs
Escapes a Javascript (JSON) String. This will not generate JSON Code out of datastructures, use L<Dotiac::DTL::Addon::JSON> for that.
<script>var="{{ "\""|escapejs|safe
otiac::DTL::Addon::json - render data into json files, uses L<JSON>.
Dotiac::DTL::Addon::jsonify - render to json (http://www.djangosnippets.org/snippets/1250/). Also uses L<JSON>.
Dotiac::DTL::
###############################################################################
#jsonify.pm
#Last Change: 2009-01-21
#Copyright (c) 2009 Marc-Seabstian "Maluku" Lucksch
#Version 0.1
#############
s file is an addon to the Dotiac::DTL project.
#http://search.cpan.org/perldoc?Dotiac::DTL
#
#jsonify.pm is published under the terms of the MIT license, which basically
#means "Do with it whate
Addon::jsonify;
use strict;
use warnings;
require JSON;
#If it is not already loaded.
require Dotiac::DTL::Filter;
require Dotiac::DTL::Value;
our $VERSION=0.1;
our $json=JSON->new()
valid_command,
'user' => qr/^[\w-]{3,100}/,
'format' => qr/^[yaml|xml|json]/,
'pass' => qr/^[\w]{10,100}$/,
},
};
my $dfv = Data::FormValid
a generic wrapper for transport encodings. This function can be
overridden to use transports like JSON or XML. The standard is a
compressed Data::Serialiser stream.
=head2 decode
The reverse of enco
et::Event;
use Proc::Safetynet::Program;
use Proc::Safetynet::ProgramStatus;
use JSON::XS 2.21;
use POE::Filter::JSON::Incr;
my $RPC_METHOD = {
'start_program' => 1,
'sto
=> $socket,
Filter => POE::Filter::JSON::Incr->new(
errors => 1,
json => JSON::XS->new->utf8->pretty->allow_blessed->convert_blessed,
def;
#print STDERR Dumper( "$self", $_[STATE], $input );
if (ref($input) eq 'POE::Filter::JSON::Incr::Error') {
$result = { result => undef, error => { message => $input->{error}, chun
ing(2,10);}var Clip=function(json,index,player){var self=this;var cuepoints={};var listeners={};self.index=index;if(typeof json=='string'){json={url:json};}extend(this,json,true);each(("Begin*,Start,P
function(json){extend(self,json);if(player.isLoaded()){player._api().fp_updateClip(json,index);}var conf=player.getConfig();var clip=(index==-1)?conf.clip:conf.playlist[index];extend(clip,json,true);}
,arg1,arg2);});return ret;}});if(json.onCuepoint){var arg=json.onCuepoint;self.onCuepoint.apply(self,typeof arg=='function'?[arg]:arg);delete json.onCuepoint;}each(json,function(key,val){if(typeof val
package Proc::Safetynet::Program::Storage::TextFile;
use strict;
use warnings;
use Carp;
use JSON::XS;
use Moose;
extends 'Proc::Safetynet::Program::Storage::Memory';
# NOTE: uses implementation in
$oh->{$ok} = $p->$ok();
}
push @out, $oh;
}
print $fh JSON::XS->new->utf8->pretty->encode( \@out );
close $fh;
}
}
sub reload {
my $self =
data = join '', <$fh>;
close $fh;
my $in;
eval {
$in = decode_json( $indata );
};
if ($@) {
croak "unable to decode programs storage fil
use POE::Wheel::ReadLine; # To read/write lines on the console.
use POE::Filter::JSON::Incr;
use JSON::XS 2.21;
use Data::Dumper;
# Specify a UNIX rendezvous to use. This is the location th
specific program named "program_name"',
],
add => [
'Parameters: <json_object_defintion>',
'Example: add { "name" : "mydaemond", "command" : "/usr/local/bin
x -c /etc/someconfig.rc" }',
'',
'Add a new program to be supervised. The JSON object fields are as follows:',
'',
' name = required,
d' => (
is => 'rw',
isa => 'Int',
required => 0,
);
sub TO_JSON {
my $self = shift;
my $o = { };
foreach my $k (keys %$self) {
next if ($k =~
stener' => (
is => 'rw',
isa => 'Bool',
required => 0,
);
sub TO_JSON {
my $self = shift;
my $o = { };
foreach my $k (keys %$self) {
$o->{$k} = $se