Thread JSON UTF decode (46 answers)
Opened by bianca at 2013-06-17 06:12

GwenDragon
 2013-06-18 16:48
#168440 #168440
User since
2005-01-17
14748 Artikel
Admin1
[Homepage]
user image
Ungetestet:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
sub decode_obj {
    my $r = $_[0];
    if ( ref($r) eq "HASH" ) {
        for ( keys %$r ) {
            $r->{$_} = decode_obj( $r->{$_} );
        }
    }
    elsif ( ( ref($r) eq "ARRAY" ) ) {
        for ( 0 .. @$r - 1 ) {
            $r->[$_] = decode_obj( $r->[$_] );
        }
    }
    unless ( ref($r) ) {    # Zeichenkette o. ä.
        $r = Encode::encode( 'ISO-8859-15', $r );
    }
    return $r;
}

View full thread JSON UTF decode