Ion
(
J/JE/JEFFOBER/Ion-0.08.tar.gz, JEFFOBER, 2018;
MetaCPAN
)
e';
use JSON::XS qw(encode_json decode_json);
use Ion;
my ($r, $w) = portable_pipe;
my $in = Connect(unblock($r)) << \&decode_json;
my $out = Connect(unblock($w)) >> \&encode_json;
=head1
the raw line
data.
=head2 EXAMPLE: JSON
use Ion;
use JSON::XS;
my $server = Listen;
$server <<= sub{ decode_json(shift) };
$server >>= sub{ encode_json(shift) };
while (my $conn = <$se
{ # $data is perl data
$conn->({foo => 'bar', baz => 'bat'}); # $conn is sent json: "{'foo': 'bar', 'baz': 'bat'}"
}
}
=head2 EXAMPLE: CHAINING
use Ion;
use Data::Dumpe