use JSON;
use Net::HTTP::Spore;
use Net::HTTP::Spore::Middleware::DefaultParams;
use Net::HTTP::Spore::Middleware::Format::Text;
my $spec = {
name => 'BrowserMob Proxy',
formats => ['json'],
[
'port'
],
description => 'Create a new proxy. Returns a JSON object {"port": your_port} on success"'
},
delete_proxy => {
method =
equired_params => [
'port'
],
description => 'returns the JSON/HAR content representing all the HTTP traffic passed through the proxy'
},
auth_b
Crawl communities. CSV is too
ill-defined. XML is too heavyweight. I'd say the same for YAML and JSON.
=head1 FUNCTIONS
=head2 read_xlogfile FILENAME => ARRAY OF HASHREFS
Takes a file and parses i
package Data::Sah::From::JSONSchema;
our $DATE = '2015-09-06'; # DATE
our $VERSION = '0.02'; # VERSION
use 5.010001;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our @
convert_json_schema_to_sah
);
sub _clauses_common {
my ($jsonsch, $sahsch) = @_;
if (exists $jsonsch->{title}) {
$sahsch->[1]{summary} = $jsonsch->{title};
if (exists $jsonsch->{description}) {
$sahsch->[1]{description} = $jsonsch->{description};
}
if (exists $jsonsch->{default}) {
$sahsch->[1]{default} = $jsonsch->{default};
e_from(
POST => '/',
'Content-Type:' => 'text/json',
'Content:' => '{ "json": "here" }',
);
=item a L<Catalyst::Action> instance + option
n - Queue like low-level interface for Gearman.
=head1 SYNOPSIS
use Queue::Gearman;
use JSON;
sub add {
my $args = shift;
return $args->{left} + $args->{rigth};
}
=> ['127.0.0.1:6667'],
serialize_method => \&JSON::encode_json,
deserialize_method => \&JSON::decode_json,
);
$queue->can_do('add');
my $task = $queue->enqueu
ation;
use File::Basename;
use File::Path;
use File::Slurp;
use HTML::Entities;
use IO::File;
use JSON;
use Time::Local;
use Metabase 0.004;
use Metabase::Fact;
use Metabase::Resource;
use CPAN::T
a::FlexSerializer->new(
detect_compression => 1,
detect_json => 1,
output_format => 'json'
);
$self->{serializer2} = Data::FlexSerializer->new(
d
me = ref $fact;
$facts{$name} = $fact->as_struct;
$facts{$name}{content} = decode_json($facts{$name}{content});
}
return \%facts;
}
sub parse_report {
my ($self,%hash) =
package StreamRoot::Manifest;
use strict;
use warnings;
use WWW::Curl::Easy;
use JSON;
our $VERSION = '0.03';
sub new {
my $class = shift;
my $self = {};
$self->{token} = shift||undef;
^2/) {
decode_json($content) if $content !~ /^$/;
}else{
if ($self->{curl}->getinfo(CURLINFO_HTTP_CODE) =~ /^4/) {
decode_json($content) if $content !~
F::FlowEntry;
use strict;
use warnings;
use Brocade::BSC::Node::OF::Match;
use Data::Walk;
use JSON -convert_blessed_universally;
# Package =======================================================
new Brocade::BSC::Node::OF::FlowEntry::Instructions;
bless ($self, $class);
# if ($params{json}) {
# die "foobar\n";
# }
if ($params{href}) {
while (my ($key, $value) =
<as_json>
# Returns : FlowEntry as formatted JSON string.
=cut ===================================================================
sub as_json {
my $self = shift;
my $json = new JSON->ca
essed weaken);
use HTTP::Status qw(:constants);
use HTTP::Request ();
use HTTP::Response ();
use JSON::XS ();
use Lim ();
use Lim::Util ();
use Lim::RPC::Callback ();
use base qw(Lim::RPC::Protocol
1 NAME
...
=head1 VERSION
See L<Lim> for version.
=cut
our $VERSION = $Lim::VERSION;
our $JSON = JSON::XS->new->utf8->convert_blessed;
our %REST_CRUD = (
GET => 'READ',
PUT => 'UPDATE',
ad1 SUBROUTINES/METHODS
=head2 Init
=cut
sub Init {
if (Lim::Config->{rpc}->{json}->{pretty}) {
$JSON->pretty(1);
}
}
=head2 Destroy
=cut
sub Destroy {
}
=head2 name
=cut
sub
tatus qw(:constants);
use YAML;
use LWP;
use HTTP::Status qw(:constants :is status_message);
use JSON -convert_blessed_universally;
use XML::Parser;
use Carp::Assert;
=head1 METHODS
=cut
# Constru
s_json>
# Returns pretty-printed JSON string representing BSC object.
=cut
sub as_json {
my $self = shift;
my $json = new JSON->canonical->allow_blessed->convert_blessed;
return $json-
p->code == HTTP_OK) {
if ($resp->content =~ /\"nodes\"/) {
my $nodes = decode_json($resp->content)->{nodes}->{node};
if (! $nodes) {
$status->code($BSC_
tworking controller.
=cut
package Brocade::BSC::Node;
use strict;
use warnings;
use YAML;
use JSON -convert_blessed_universally;
=head1 METHODS
=cut
# Constructor ==============================
===========
#
=item B<as_json>
# Returns : Returns pretty-printed JSON string representing netconf node.
=cut
sub as_json {
my $self = shift;
my $json = new JSON->canonical->allow_blesse
d->convert_blessed;
return $json->pretty->encode($self);
}
# Method ===============================================================
#
=item B<ctrl_req>
# Parameters: $method (string, req) HTT
$_[0];
}
=item $hash_ref = $error->TO_JSON
Returns a hash reference describing the error, this is to support passing
objects to L<JSON::XS>.
=cut
sub TO_JSON {
{
'Lim::Error' => {
use common::sense;
use Carp;
use Scalar::Util qw(weaken);
use Log::Log4perl ();
use DBI ();
use JSON::XS ();
use AnyEvent ();
use AnyEvent::Util ();
use Lim ();
=encoding utf8
=head1 NAME
Lim::
%args = ( @_ );
my $self = {
logger => Log::Log4perl->get_logger($class),
json => JSON::XS->new->utf8->convert_blessed,
busy => 0
};
bless $self, $class;
weaken
$response = $self->{json}->incr_parse($buf);
};
if ($@) {
Lim::DEBUG and $self->{logger}->debug('Response JSON parse failed: ', $@);
ense;
use Carp;
use YAML::Any ();
=encoding utf8
=head1 NAME
Lim - Framework for RESTful JSON/XML, JSON-RPC, XML-RPC and SOAP
=head1 VERSION
Version 0.20
=cut
our $VERSION = '0.20';
our $CONFI
verify_require_client_cert => 1,
ca_path => '/etc/lim/ssl/certs'
},
json => {
pretty => 0
}
},
agent => {
config_file => '',
u
over multiple protocols.
It uses AnyEvent for async operations and SOAP::Lite, XMLRPC::Lite and JSON::XS
for processing protocol messages.
There are 3 parts in Lim that can work independenly, a Ser
onstants);
use HTTP::Request ();
use HTTP::Response ();
use LWP::MediaTypes ();
use Fcntl ();
use JSON::XS ();
use Lim ();
use Lim::Util ();
use Lim::RPC::Callback ();
use base qw(Lim::RPC::Protocol
1 NAME
...
=head1 VERSION
See L<Lim> for version.
=cut
our $VERSION = $Lim::VERSION;
our $JSON = JSON::XS->new->utf8->convert_blessed;
=head1 SYNOPSIS
...
=head1 SUBROUTINES/METHODS
=head2 In
$cb->cb->($response);
return 1;
}
if (defined $query->{jsonpCallback}) {
my ($content, $buf);
while (sysread(FILE, $buf, 64*1024)) {
m::RPC::Protocol::JSONRPC1;
use common::sense;
use Carp;
use Scalar::Util qw(blessed weaken);
use HTTP::Status qw(:constants);
use HTTP::Request ();
use HTTP::Response ();
use JSON::XS ();
use Lim
$JSON = JSON::XS->new->utf8->convert_blessed;
our $ID = 1;
our $ID_OVERFLOW = 2^32;
=head1 SYNOPSIS
...
=head1 SUBROUTINES/METHODS
=head2 Init
=cut
sub Init {
if (Lim::Config->{rpc}->{json}
->{pretty}) {
$JSON->pretty(1);
}
}
=head2 Destroy
=cut
sub Destroy {
}
=head2 name
=cut
sub name {
'jsonrpc1';
}
=head2 serve
=cut
sub serve {
}
=head2 handle
=cut
sub han
m::RPC::Protocol::JSONRPC2;
use common::sense;
use Carp;
use Scalar::Util qw(blessed weaken);
use HTTP::Status qw(:constants);
use HTTP::Request ();
use HTTP::Response ();
use JSON::XS ();
use Lim
$JSON = JSON::XS->new->utf8->convert_blessed;
our $ID = 1;
our $ID_OVERFLOW = 2^32;
=head1 SYNOPSIS
...
=head1 SUBROUTINES/METHODS
=head2 Init
=cut
sub Init {
if (Lim::Config->{rpc}->{json}
->{pretty}) {
$JSON->pretty(1);
}
}
=head2 Destroy
=cut
sub Destroy {
}
=head2 name
=cut
sub name {
'jsonrpc2';
}
=head2 serve
=cut
sub serve {
}
=head2 handle
=cut
sub han
package WWW::SuperMan;
use Slurp;
use JSON;
use LWP::UserAgent;
our $VERSION = 0.01;
sub new {
my($class, %cnf) = @_;
my $self = bless {
user => $cnf{ user },
pass => $cnf{ pass },
u
},
password => $self->{ pass }
}
);
return {} unless $res->is_success;
return _deJson( $res );
}
sub getCode {
my ( $self, $img_file ) = @_;
my $url = 'http://api2.sz789.net:88/R
uccess;
return _deJson( $res );
}
sub _deJson {
my $res = shift;
my $json = $res->content;
eval {
$json = from_json( $json );
};
return {} if $@;
return $json;
}
1;
__END__
=he
= @_) {
$self->{vlan_id}->{vlan_id} = $vid;
$self->{vlan_id}->{vlan_id_present} = JSON::true;
}
return $self->{vlan_id}->{vlan_id};
}
sub pcp {
my ($self, $pcp) = @_;
$
gexp::Common; # balanced paren matching
use HTTP::Status qw(:constants :is status_message);
use JSON -convert_blessed_universally;
=head1 METHODS
=cut
# Constructor ==============================
s = $1) =~ s/flow-node-inventory:flow-feature-capability-//g);
$feature_info_ref = decode_json($features);
$status->code($BSC_OK);
}
else {
$status->http_err($resp);
my $node_connector_json = ($resp->content =~ /$RE{balanced}{-keep}{-begin => "\"node-connector\":\["}{-end => "]"}/ && $1);
@port_list = ($node_connector_json =~ /\"flow-node-inventory