{"id":"/heatingCircuits/hc1/switchPrograms/A","type":"switchProgram","setpointProperty":{"id":"/heatingCircuits/hc1/temperatureLevels","uri":"http://192.168.178.58/heatingCircuits/hc1/temperatureLevels"},"maxNbOfSwitchPoints":42,"maxNbOfSwitchPointsPerDay":6,"switchPointTimeRaster":15,"writeable":1,"switchPoints":[{"dayOfWeek":"Mo","setpoint":"comfort2","time":240},{"dayOfWeek":"Mo","setpoint":"eco","time":1320},{"dayOfWeek":"Tu","setpoint":"comfort2","time":240},{"dayOfWeek":"Tu","setpoint":"eco","time":1320},{"dayOfWeek":"We","setpoint":"comfort2","time":240},{"dayOfWeek":"We","setpoint":"eco","time":1320},{"dayOfWeek":"Th","setpoint":"comfort2","time":240},{"dayOfWeek":"Th","setpoint":"eco","time":1320},{"dayOfWeek":"Fr","setpoint":"comfort2","time":240},{"dayOfWeek":"Fr","setpoint":"eco","time":1320},{"dayOfWeek":"Sa","setpoint":"comfort2","time":360},{"dayOfWeek":"Sa","setpoint":"eco","time":1380},{"dayOfWeek":"Su","setpoint":"comfort2","time":360},{"dayOfWeek":"Su","setpoint":"eco","time":1380}]}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
### Console Message if enabled
print ": $JsonId\n";
print(" - JsonResponse : " . $json . "\n");}
print(" - JSON Type : " . $json->{type} . "\n");}
print(" - JSON setpointProperty : " . $json->{setpointProperty}. "\n");}
print(" - JSON switchPoints : " . $json->{switchPoints} . "\n");}
my @temparray = $json->{switchPoints};
print(" - JSON temparray : ");
print @temparray;
print("\n");
print(" - JSON temparray[1] : ");
print $temparray[1];
print("\n");
1
2
3
4
5
6
- JsonResponse : HASH(0xc88568)
- JSON Type : switchProgram
- JSON setpointProperty : HASH(0x1469af8)
- JSON switchPoints : ARRAY(0x1468d30)
- JSON temparray : ARRAY(0x1468d30)
- JSON temparray[1] :
2015-03-09T10:26:21 LinuxerHi,
Wenn Du eine Array-Referenz wieder als Array nutzen willst, dann musst Du sie derefenzieren.
Als $array_reference kann dann auch die Angabe eines $json->{switchPoints} dienen.
1
2
3
4
5
6
- JsonResponse : HASH(0x126cf18)
- JSON Type : switchProgram
- JSON setpointProperty : HASH(0x1283268)
- JSON switchPoints : ARRAY(0x1280080)
- JSON temparray : HASH(0x12835f8)HASH(0x1280368)HASH(0x126cf78)HASH(0x10cbbc0)HASH(0x126ab08)HASH(0x12834f0)HASH(0x1283028)HASH(0x1292ad0)HASH(0x127fcf0)HASH(0x1293778)HASH(0x127ff18)HASH(0x12831a8)HASH(0x126ceb8)HASH(0x1282920)HASH(0x126d950)HASH(0x126d6f8)HASH(0x1280350)HASH(0x96d4f8)HASH(0x127fff0)HASH(0x1081b70)HASH(0x12935c8)HASH(0x126dc38)HASH(0x1293340)HASH(0x10cb470)
- JSON temparray[1] : HASH(0x1280368)
2015-03-09T10:33:57 PerlentaucherAaaargh! Wer programmiert bloss so was...
perldoc perlref
QuoteAaaargh! Wer programmiert bloss so was...
2015-03-09T10:33:57 PerlentaucherAaaargh! Wer programmiert bloss so was...
print to_json($json, {utf8 => 1, pretty => 1});
1 2 3 4 5
print " - JSON setpointProperty ID : " . $json->{setpointProperty}->{id}. "\n"; print " - JSON setpointProperty URI: " . $json->{setpointProperty}->{uri}. "\n"; print " - JSON switchPoint 01 setpoint: " . $json->{switchPoints}->[0]->{setpoint} . "\n"; print " - JSON switchPoint 01 dayOfWeek: " . $json->{switchPoints}->[0]->{dayOfWeek} . "\n"; print " - JSON switchPoint 01 time: " . $json->{switchPoints}->[0]->{time} . "\n";
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{
"id" : "/heatingCircuits/hc1/switchPrograms/A",
"type" : "switchProgram",
"setpointProperty" : {
"id" : "/heatingCircuits/hc1/temperatureLevels",
"uri" : "http://192.168.178.58/heatingCircuits/hc1/temperatureLevels"
},
"maxNbOfSwitchPoints" : 42,
"maxNbOfSwitchPointsPerDay" : 6,
"switchPointTimeRaster" : 15,
"writeable" : 1,
"switchPoints" : [{
"dayOfWeek" : "Mo",
"setpoint" : "comfort2",
"time" : 240
}, {
"dayOfWeek" : "Mo",
"setpoint" : "eco",
"time" : 1320
}, {
"dayOfWeek" : "Tu",
"setpoint" : "comfort2",
"time" : 240
}, {
"dayOfWeek" : "Tu",
"setpoint" : "eco",
"time" : 1320
}, {
"dayOfWeek" : "We",
"setpoint" : "comfort2",
"time" : 240
}, {
"dayOfWeek" : "We",
"setpoint" : "eco",
"time" : 1320
}, {
"dayOfWeek" : "Th",
"setpoint" : "comfort2",
"time" : 240
}, {
"dayOfWeek" : "Th",
"setpoint" : "eco",
"time" : 1320
}, {
"dayOfWeek" : "Fr",
"setpoint" : "comfort2",
"time" : 240
}, {
"dayOfWeek" : "Fr",
"setpoint" : "eco",
"time" : 1320
}, {
"dayOfWeek" : "Sa",
"setpoint" : "comfort2",
"time" : 360
}, {
"dayOfWeek" : "Sa",
"setpoint" : "eco",
"time" : 1380
}, {
"dayOfWeek" : "Su",
"setpoint" : "comfort2",
"time" : 360
}, {
"dayOfWeek" : "Su",
"setpoint" : "eco",
"time" : 1380
}
]
}
1 2 3 4 5 6 7 8 9 10 11 12 13
my $control = { properties => { "id" => "/heatingCircuits/hc1/switchPrograms/A", "type" => "switchProgram", "setpointPropertyID" => "/heatingCircuits/hc1/temperatureLevels", "setpointPropertyURI" => "http://192.168.178.58/heatingCircuits/hc1/temperatureLevels", "maxNbOfSwitchPoints" => 42, "maxNbOfSwitchPointsPerDay" => 6, "switchPointTimeRaster" => 15, "writeable" => 1, }, switchpoints => [{},{},{}] };
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
### Console Message if enabled
print ": $JsonId\n";
print(" - JsonResponse : " . $json . "\n");
print(" - JSON Type : " . $json->{type} . "\n");
print(" - JSON maxNbOfSwitchPoints : " . $json->{maxNbOfSwitchPoints} . "\n");
print(" - JSON maxNbOfSwitchPointsPerDay : " . $json->{maxNbOfSwitchPointsPerDay} . "\n");
print(" - JSON switchPointTimeRaster : " . $json->{switchPointTimeRaster} . "\n");
print(" - JSON writeable : " . $json->{writeable} . "\n");
print(" - JSON setpointProperty : " . $json->{setpointProperty} . "\n");
print(" - JSON switchPoints : " . $json->{switchPoints} . "\n");
my @temparray = @{$json->{switchPoints}};
my $item;
foreach $item (@temparray)
{
print(" - hash dayOfWeek : " . $item->{dayOfWeek} . " - setpoint : " . $item->{setpoint} . " - setpoint : " . $item->{time}/0.6 . "\n");
}
2015-03-10T11:37:45 Perlentaucher... demnach dürfte der Code
!Achtung ungetestet!
mir das gesamte Hash Linienweise ausgeben...
2015-03-10T18:12:53 PerlentaucherDer komplette Befehl lautet:
if ($hash->{CONSOLEMESSAGE} == true) {print(" - JSON switchPoints : " . $json->{switchPoints} . "\n");}
Jetzt hauts hin, oder?
Bareword "true" not allowed while "strict subs" in use
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
The following Service can be read and is writeable : /heatingCircuits/hc1/switchPrograms/A
- JsonResponse : HASH(0x1eea3e0)
- JSON Type : switchProgram
- JSON setpointProperty : HASH(0x1efe3b8)
- JSON maxNbOfSwitchPointsPerDay : 6
- JSON switchPointTimeRaster : 15
- JSON writeable : 1
- JSON setpointProperty : HASH(0x1efe3b8)
- JSON switchPoints : ARRAY(0x1eea500)
- hash dayOfWeek : Mo - setpoint : comfort2 - setpoint : 400
- hash dayOfWeek : Mo - setpoint : eco - setpoint : 2200
- hash dayOfWeek : Tu - setpoint : comfort2 - setpoint : 400
- hash dayOfWeek : Tu - setpoint : eco - setpoint : 2200
- hash dayOfWeek : We - setpoint : comfort2 - setpoint : 400
- hash dayOfWeek : We - setpoint : eco - setpoint : 2200
- hash dayOfWeek : Th - setpoint : comfort2 - setpoint : 400
- hash dayOfWeek : Th - setpoint : eco - setpoint : 2200
- hash dayOfWeek : Fr - setpoint : comfort2 - setpoint : 400
- hash dayOfWeek : Fr - setpoint : eco - setpoint : 2200
- hash dayOfWeek : Sa - setpoint : comfort2 - setpoint : 600
- hash dayOfWeek : Sa - setpoint : eco - setpoint : 2300
- hash dayOfWeek : Su - setpoint : comfort2 - setpoint : 600
- hash dayOfWeek : Su - setpoint : eco - setpoint : 2300