【发布时间】:2015-07-27 21:56:48
【问题描述】:
我需要从 json 文件向 dashing Meter 发送一个值: 解析也不起作用 content = JSON.parse(file.read)
require 'json'
file = File.open('/mnt/json/process1.json')
contents = file.read
SCHEDULER.every '2s' do
contents["poolused"] = { label: "poolused" , value: (contents["poolused"][:value])}
send_event('synergy3', { items: contents.values})
end
这是我的 json 文件
{
"label":"value",
"PoolName": "SDS2_D2600-SAS-450G-15K",
"poolpercent": "70",
"Date": "07/23/2015 15:33:57",
"pooltotal": "3540529446912",
"poolused": "2466384969728"
}
错误:
scheduler caught exception:
undefined method `[]' for nil:NilClass
/home/toto/dashboard_v2/jobs/sample.rb:22:in `block in <top (required)>'
【问题讨论】: