pers::JsonEncoder;
use strict;
use warnings;
use JSON::MaybeXS qw(JSON);
use Moo::Role;
our $VERSION = "0.01";
has _json_encoder => (
is => 'ro',
lazy => 1,
builder => '_build_json_enco
handles => {
encode_json => 'encode',
decode_json => 'decode',
},
);
sub _build_json_encoder { JSON->new->utf8(1); }
sub json_bool { $_[1] ? JSON->true : JSON->false }
1;
__END__
=
ead1 NAME
WebApp::Helpers::JsonEncoder - Simple role for en/decoding JSON
=head1 SYNOPSIS
package MyTunes::Resource::CD;
use Moo;
with 'WebApp::Helpers::JsonEncoder';
has title