| 1 | package File::Serialize::Serializer::JSON::MaybeXS; | ||||||||||
| 2 | 8 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||
| 3 | #ABSTRACT: JSON::MaybeXS serializer for File::Serialize | ||||||||||
| 4 | 8 | $File::Serialize::Serializer::JSON::MaybeXS::VERSION = '1.5.0'; | |||||||||
| 5 | 8 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 8 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 8 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 8 | with 'File::Serialize::Serializer'; | |||||||||
| 10 | |||||||||||
| 11 | 56 | ▶ | sub extensions { qw/ json js / }; | ||||||||
|
Subroutine
extensions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 12 | |||||||||||
| 13 | sub serialize { | ||||||||||
| 14 | my( $self, $data, $options ) = @_; | ||||||||||
| 15 | JSON::MaybeXS->new(%$options)->encode( $data); | ||||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | sub deserialize { | ||||||||||
| 19 | my( $self, $data, $options ) = @_; | ||||||||||
| 20 | JSON::MaybeXS->new(%$options)->decode( $data); | ||||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | sub groom_options { | ||||||||||
| 24 | 37 | ▶ | my( $self, $options ) = @_; | ||||||||
|
Subroutine
groom_options: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 25 | |||||||||||
| 26 | 37 | my %groomed; | |||||||||
| 27 | 37 | for my $k( qw/ pretty canonical allow_nonref / ) { | |||||||||
| 28 | 111 | ▶ | $groomed{$k} = $options->{$k} if defined $options->{$k}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 37 | return \%groomed; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 8 | 1; | |||||||||
| 35 | |||||||||||
| 36 | __END__ | ||||||||||