Line # Revision Author
1 478 ahitrov <%once>
2
3 use JSON::XS;
4 484 ahitrov use Data::Recursive::Encode;
5 478 ahitrov
6 </%once>
7 <%args>
8
9 $name => undef
10 $SETS => undef
11 $object => undef
12
13 </%args>
14 <%init>
15
16 return undef unless ref($SETS);
17 return undef unless $name;
18 return undef unless $SETS->{$name};
19
20 my ($prop) = grep { $_->{attr} eq $name } $object->structure;
21 my $class = $object->class;
22 484 ahitrov my $is_extra = scalar (grep { ref $_ && $_->{attr} eq $name } $class->class_table->required_properties) ? 0 : 1;
23 478 ahitrov
24 my $result;
25 if ( $is_extra && !$prop->{serialize} ) {
26 484 ahitrov eval { $result = Data::Recursive::Encode->encode_utf8( JSON::XS->new->utf8->decode($SETS->{$name}) ) };
27 478 ahitrov } else {
28 $result = $SETS->{$name};
29 }
30 484 ahitrov warn "\nJSON\n";
31 478 ahitrov warn Dumper $result;
32 return $result;
33
34 </%init>