[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Get info out a JSON file
I'm attempting to read someone elses JSON files the structure of which is
(using Data Dumper):
$VAR1 = {
'smtp' => {
'up_time' => '*',
'checks' => 2,
'problem_send_to' => '*',
'input' => '',
'marginal_send_to' => '*',
'port' => 25,
'marginal' => '*',
'seconds' => 2,
'pow' => '*',
'critical' => '*',
'vital' => 'no',
'up_days' => '*'
},
'ssh' => {
'up_time' => '*',
'checks' => 2,
'problem_send_to' => '*',
'input' => '',
'marginal_send_to' => '*',
'hostname' => 'reginald.some.net',
'port' => 22,
'marginal' => 10,
'seconds' => 2,
'pow' => '*',
'critical' => '*',
'vital' => 'no',
'up_days' => '*'
}
};
All I'm interested in, is the value of the port number for each service,
if I know the service name in advance I can just do something like
print $services->{ssh}->{port};
print $services->{smtp}->{port};
which is well and good, but how do I loop through them if I don't know the
service name (ssh, smtp, whatever) in advance? NB the service name doesn't
always correspond to what is in /etc/services.
h.
-
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.