shrefs in a md5 sum.
This I will compare to later processing.
My first approach was to use encode_json string.
Unfortunately, the resort was not very consistent.
So I wrote my first cpan packet in or
ght implementation of Spore specification
use Moo;
use Sub::Install;
use Try::Tiny;
use Carp;
use JSON::MaybeXS;
use Data::Rx;
use LWP::UserAgent;
use URI;
use File::ShareDir ':ALL';
use Subclass::Of;
d => 1,
coerce => sub {
my $json_spec = $_[0];
my $spec;
# it could be a file
try {
open my $fh, '<', $json_spec or croak 'Cannot read the spec file'
spec = decode_json(<$fh>);
close $fh;
}
catch {
try {
$spec = decode_json($json_spec);
}
# it is not json, so we are re
;
my $response = Net::HTTP::Knork::Response->new(
200, ['Content-Type', 'application/json'], '{"foo":1}';
);
$response->request($request);
=head1 DESCRIPTION
Net::HTTP::Knork::R
hen the body is sets for the first time.
=item content_type
$res->content_type('application/json');
my $ct = $res->content_type;
Gets or sets the content type of the response body
=item co
ype' => 'application/json']);
Gets or sets HTTP response headers.
=item header
my $cl = $res->header('Content-Length');
$res->header('Content-Type' => 'application/json');
Shortcut for C<<
simple;
my $sm_status = $simple->sm_publish('{"say": "hello"}', content_type => "application/json");
die sm_get_error_desc($sm_status) if $sm_status;
$simple->sm_destroy();
}
sub consu
use Carp;
use Data::Dumper qw/Dumper/;
use English qw/ -no_match_vars /;
use TryCatch;
use JSON qw/decode_json/;
extends 'W3C::SOAP::Client';
our $VERSION = version->new('0.007');
has _response =>
t );
}
elsif ( $type eq 'application/json' ) {
# process JSON
$content = decode_json($content);
}
elsif ( $type eq 'text
It supports less
features (currently only supports sending/receiving Riap request and response in
JSON encoding, no encryption, no authentication, no sending of logging
messages). It is suitable for l
he following format:
"j" <JSON> <CRLF>
That is, the lowercase letter C<j> followed by JSON data (must all be in one
line), followed by CRLF.
=head2 Response
"j" <JSON> <CRLF>
That is, the lower
case letter C<j> followed by enveloped result encoded in JSON
(will all be in one line) and a single <CRLF>. The next request can then be sent
by client.
If client/server sends an invalid request/res
at is, the subsequent circular references will be deep-copied. This makes it
safe to transport to JSON, for example.
Sometimes it doesn't work, for example:
$data = [1];
push @$data, $data;
at is, the subsequent circular references will be deep-copied. This makes it
safe to transport to JSON, for example.
Sometimes it doesn't work, for example:
$data = [1];
push @$data, $data;
Cloni
rg_json => {
summary => 'Pass per_arg_json=1 to Perinci::Sub::GetArgs::Argv',
schema => 'bool',
},
per_arg_yaml => {
summary => 'Pass per_arg_json=1
meta=>$meta, meta_is_normalized=>1, common_opts=>$common_opts,
per_arg_json => $args{per_arg_json},
per_arg_yaml => $args{per_arg_yaml},
);
};
$gcd_res->[0]
Perinci::Sub::Complete;
my $compres;
last if $ospec->{is_json} || $ospec->{is_yaml} ||
$ospec->{is_base64};
#say "D
aits;
use W3C::SOAP::WADL::Meta::Method;
use MooseX::Types::Moose qw/Str Int HashRef/;
use JSON qw/decode_json/;
use W3C::SOAP::Utils qw/ns2module/;
use TryCatch;
Moose::Exporter->setup_import_method
element => './@element';
has_xpath_value profile => './@profile';
has_xpath_value json => './@json:serialize';
has_xpath_object_list param => (
'./wadl:param' => 'W3C::SOAP::WADL::Do
B<log_level> => I<any>
=item * B<pass_cmdline_object> => I<any> (default: 0)
=item * B<per_arg_json> => I<any>
=item * B<per_arg_yaml> => I<any>
=item * B<program_name> => I<any>
=item * B<read_
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};
Win32"){
use LWP::UserAgent;
use HTTP::Request;
use Time::Local;
use JSON qw(decode_json encode_json);
use MIME::Base64 (qw(encode_base64));
use Time::HiRes (qw/gettimeofday/);
} else {
use LWP::UserAgent;
use HTTP::Request;
use Time::Local;
use JSON qw(decode_json encode_json);
use MIME::Base64 (qw(encode_base64));
use Time::HiRes (qw/gettimeofday/);
ponse->content eq '') { # work around for JSON module which does not handle blank content well
return "";
} else {
return decode_json($response->content);
}
} else {
::CmdLine->new(url => '/MyApp/add_array')->run;
To execute the program:
% myapp --a1-json '[1,2,3]' --a2-json '[4,5,6]'
% myapp '[1,2,3]' '[4,5,6]'; # ditto
.------.
| 5 |
| 7 |
| 9 |
'------'
To output in other formats:
% myapp '[1,2,3]' '[4,5,6]' --format json
[200","OK",[5,7,9]]
% myapp '[1,2,3]' '[4,5,6]' --format=yaml
- 200
- OK
-
- 5
- 7
- 9
To
(using summary and
other information from metadata), output result in a variety of formats (YAML,
JSON, text, and more), among other things. Other features not demonstrated in
this tutorial include su
load
=head2 Using the server for completion
# foo-complete
#!perl
use HTTP::Tiny::UNIX;
use JSON;
my $hres = HTTP::Tiny::UNIX->new->post_form(
'http:/tmp/app1.sock//api/Perinci/CmdLine/Ser
NV{COMP_LINE},
point => $ENV{COMP_POINT},
'-riap-fmt' => 'json',
},
);
my $rres = decode_json($hres->{content});
print $rres->[2];
Activate bash tab completion:
% chmod
pace wadl => 'http://wadl.dev.java.net/2009/02';
add_xpath_namespace json => 'http://rest.domain.gdl.optus.com.au/rest/3/common-json';
has_xpath_value target_namespace => './@targetNamespace';
has_xp
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
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_
PANTS.txt
Makefile
Makefile.old
MANIFEST.bak
META.json
META.yml
pm_to_blib
README
>,
],
);
$builder.cre
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)) {