age Flux::Format::JSON;
# ABSTRACT: JSON format for flux storages
=head1 SYNOPSIS
use Flux::Format::JSON;
my $json_storage = Flux::Format::JSON->wrap($storage);
$json_storage->write({
ding with \n
my $in = $json_storage->in(...);
$in->read; # { foo => "bar" }
=cut
use Moo;
with 'Flux::Format';
use JSON;
use Flux::Simple qw(mapper);
has 'json' => (
is => 'lazy',
=> sub {
return JSON->new->utf8->allow_nonref;
},
);
sub encoder {
my $self = shift;
return mapper {
my $item = shift;
return $self->json->encode($item)."\n";