ackage Cikl::Codecs::JSON;
use strict;
use warnings;
use Cikl::Models::Event;
require JSON::XS;
use Mouse;
use Cikl::Codecs::CodecRole;
use namespace::autoclean;
our $JSON = JSON::XS->new()->utf8(1)
ion/json";
}
sub encode_event {
my $self = shift;
my $event = shift;
return $JSON->encode($event->to_hash());
}
sub decode_event {
my $self = shift;
my $json = shift;
my $data = $JSON->d
ecode($json);
return Cikl::Models::Event->from_hash($data);
}
__PACKAGE__->meta->make_immutable;
1;
t::Parsers::ParseJson;
use strict;
use warnings;
use JSON::XS;
use Mouse;
use Cikl::Smrt::Parser;
extends 'Cikl::Smrt::Parser';
use namespace::autoclean;
use constant NAME => 'json';
sub name { ret
}
}
$broker->emit($h);
};
$self->_parse_json_as_stream($fh, $cb);
return(undef);
}
# This will parse the JSON as a stream, which uses significantly less memory
# than read
h this, we have to strip off the '[' and ']' that we
# expect to surround the main JSON array in order to get the JSON lib to emit
# individual objects. We must also remove any commas that appear betw
;
use Scalar::Util qw(blessed);
use Cikl::Codecs::JSON;
use namespace::autoclean;
has 'codec' => (
is => 'ro',
default => sub { Cikl::Codecs::JSON->new() }
);
has 'running' => (
is => 'rw',