Revision 484 (by ahitrov, 2015/03/05 14:31:55) UTF-8 codepage symbols conversion
<%once>

    use JSON::XS;
    use Data::Recursive::Encode;

</%once>
<%args>

        $name	=> undef
        $SETS	=> undef
	$object	=> undef

</%args>
<%init>

	return undef	unless ref($SETS);
	return undef	unless $name;
	return undef	unless $SETS->{$name};

	my ($prop) = grep { $_->{attr} eq $name } $object->structure;
	my $class = $object->class;
	my $is_extra = scalar (grep { ref $_ && $_->{attr} eq $name } $class->class_table->required_properties) ? 0 : 1;

	my $result;
	if ( $is_extra && !$prop->{serialize} ) {
		eval { $result = Data::Recursive::Encode->encode_utf8( JSON::XS->new->utf8->decode($SETS->{$name}) ) };
	} else {
		$result = $SETS->{$name};
	}
	warn "\nJSON\n";
	warn Dumper $result;
	return $result;

</%init>