PerlIO::via::json;
use 5.008001;
use strict;
use warnings;
our $VERSION = '0.02';
use XML::XML2JSON;
### PerlIO::via interface
sub PUSHED {
bless {
obj => XML::XML2JSON->new()
}
$t = <$fh>;
(defined $t) ? $self->{obj}->xml2json($t) : undef;
}
sub WRITE {
my ($self, $buf, $fh) = @_;
if (print $fh $self->{obj}->json2xml($buf)) {
return length($buf);
}
::json - PerlIO layer to convert to and from JSON
=head1 SYNOPSIS
use PerlIO::via::json;
open my $fh, '<:via(json)', 'file.xml' or die "...: $!";
my $json = <$fh>;
open my $fh, '>:via(json)