Thread Unicode Zeichen in JSON umwandeln (5 answers)
Opened by Franz at 2020-01-08 21:13

Daxim
 2020-01-09 10:00
#191080 #191080
User since
2007-08-01
114 Artikel
BenutzerIn
[Homepage]
user image
Du möchtest JSON dekodieren. Was Nachbar Linuxer gesagt hat, ist Pfusch.

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use HTTP::Tiny qw();
use JSON::MaybeXS qw(decode_json);
use Text::Xslate qw();

my $response = HTTP::Tiny->new->get('https://api.crossref.org/works/10.1177/0974928419874548');
die($response->{status}, $response->{reason}) unless $response->{success};

my $template = Text::Xslate->new;
my $abstract = decode_json($response->{content})->{message}{abstract};
STDOUT->binmode(':encoding(UTF-8)');
STDOUT->print($template->render_string(<<'HTML', {abstract => $abstract}));
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
    </head>
    <body>
        <p><: $abstract :></p>
    </body>
</html>
HTML


__END__

    <body>
        <p>&lt;jats:p&gt; ‘Jihadism’ (also kno…

View full thread Unicode Zeichen in JSON umwandeln