@@ -2,7 +2,7 @@ package Dancer2::Serializer::JSON;
22# ABSTRACT: Serializer for handling JSON data
33
44use Moo;
5- use Ref::Util qw< is_arrayref is_hashref > ;
5+ use Ref::Util qw< is_plain_arrayref is_plain_hashref > ;
66use JSON::MaybeXS ();
77use Encode qw( decode FB_CROAK) ;
88use Scalar::Util ' blessed' ;
@@ -76,14 +76,15 @@ sub _ensure_characters {
7676 return $entity if !defined $entity ;
7777 return _ensure_scalar( $entity , $strict_utf8 , $self ) if !ref $entity ;
7878
79- if ( is_arrayref ($entity ) ) {
79+ if ( is_plain_arrayref ($entity ) ) {
8080 for my $i ( 0 .. $# {$entity } ) {
8181 $entity -> [$i ] = _ensure_characters( $entity -> [$i ], $strict_utf8 , $self );
8282 }
8383 return $entity ;
8484 }
8585
86- if ( is_hashref($entity ) ) {
86+ if ( is_plain_hashref($entity ) ) {
87+ my %ret ;
8788 for my $key ( keys %{$entity } ) {
8889 my $value = $entity -> {$key };
8990 my $decoded_key = _ensure_scalar( $key , $strict_utf8 , $self );
@@ -92,12 +93,12 @@ sub _ensure_characters {
9293
9394 if ( $decoded_key ne $key ) {
9495 delete $entity -> {$key };
95- $entity -> {$decoded_key } = $decoded_value ;
96+ $ret {$decoded_key } = $decoded_value ;
9697 } else {
97- $entity -> {$key } = $decoded_value ;
98+ $ret {$key } = $decoded_value ;
9899 }
99100 }
100- return $entity ;
101+ return \ %ret ;
101102 }
102103
103104 return $entity ;
0 commit comments