package JSON::Client;
use warnings;
use strict;
use utf8;
use Carp;
use JSON::Parse '0.61', 'valid_json';
use JSON::Create '0.35';
use JSON::Server;
use IO::Socket;
our $VERSION = '0.03';
sub new
{
verbose => $verbose,
jc => JSON::Create->new (downgrade_utf8 => 1,),
jp => JSON::Parse->new (),
};
$client->{jp}->upgrade_utf8 (1);
return $client;
}
sub JSON::Client::send
{
my ($j
@_;
if (! $input) {
carp "Nothing to send";
return {error => 'empty input'};
}
my $json_msg = $jcl->{jc}->run ($input);
my $sock = make_sock ($jcl->{port});
if (! $sock) {
retu
package JSON::Server;
use warnings;
use strict;
use Carp;
use utf8;
our $VERSION = '0.03';
use IO::Socket;
use IO::Select;
use JSON::Create '0.35', ':all';
use JSON::Parse '0.61', ':all';
$SIG{PIPE}
t specified";
}
$gs->{jc} = JSON::Create->new (
indent => 1,
sort => 1,
downgrade_utf8 => 1,
);
$gs->{jc}->bool ('boolean');
$gs->{jp} = JSON::Parse->new ();
$gs->{jp}->upgr
valid_json ($got)) {
if ($gs->{verbose}) {
vmsg ("Not valid json");
}
$gs->reply ($fh, {error => 'invalid JSON'});
next;
}
if ($gs->{verbose}) {
vmsg ("Validated as JSON");
tware/install/bin/perl
use warnings;
use strict;
use utf8;
use FindBin '$Bin';
use lib "$Bin/../lib";
use JSON::Server;
my $server = JSON::Server->new (port => 3737, verbose => 1);
$server->serve ();
=encoding UTF-8
=head1 NAME
JSON::Server - JSON-only server
=head1 SYNOPSIS
use JSON::Server;
my $js = JSON::Server->new (handler => \& hello, port => '7777', data => 'OK');
wh
}
(This example is included as L<F<synopsis.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Server-0.03/examples/synopsis.pl> in the distribution.)
Then test your server:
$ perl exam
}
{"JSON::Server::control":"close"}
{
"JSON::Server::response":"closing"
}
Connection closed by foreign host.
=head1 VERSION
This documents version 0.03 of JSON-Server
=encoding UTF-8
=head1 NAME
JSON::Client - Example client for JSON::Server
=head1 VERSION
This documents version 0.03 of JSON::Client
corresponding to L<git commit ad3eb95dc23ace0b097b7e253b1c4
enkasminbullock/json-server/commit/ad3eb95dc23ace0b097b7e253b1c4047a2c243bd> released on Sat Apr 30 14:09:31 2022 +0900.
=head1 DESCRIPTION
This is an example client module for L<JSON::Server> which
a JSON::Server server.
=head1 SYNOPSIS
my $client = JSON::Client->new (
port => '5555', # This is the port of the server we are using
);
=head1 METHODS
=head2 new
Make a new JSON