Leser: 15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"Body" : {
"Data" : {
"DAY_ENERGY" : {
"Unit" : "Wh",
"Values" : {
"1" : 4241
}
},
"PAC" : {
"Unit" : "W",
"Values" : {
"1" : 900
}
}
},
}
2020-02-04T13:00:14 chmod777Na das ist einfach:Mein Wunsch: den Wert 990 aus Zeile 13 in eine Variable zu schreiben.
$var = 990;
1 2 3 4 5 6
use JSON::XS qw(decode_json); $text = getMyDownloadedJson(); my $content = decode_json($text); say $content->{'Body'}{'Data'}{'PAC'}{'Values'}{'1'};
1
2
3
4
5
6
7
8
sub pv_leistung {
my $ua = LWP::UserAgent->new;
my $response = $ua->get("http://192.168.1.4/solar_api/v1/GetInverterRealtimeData.cgi?Scope=System");
my $content = parse_json ($response->decoded_content);
return $content->{'Body'}->{'Data'}->{'PAC'}->{'Values'}->{'1'};
}
return $content->{'Body'}->{'Data'}->{'PAC'}->{'Values'}->{'1'};
return $content->{'Body'}{'Data'}{'PAC'}{'Values'}{'1'};
return $content->{Body}{Data}{PAC}{Values}{1};