I need to send a value to dashing meter from a json file : Parse dont work too contents = 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
This is my json file
{
"label":"value",
"PoolName": "SDS2_D2600-SAS-450G-15K",
"poolpercent": "70",
"Date": "07/23/2015 15:33:57",
"pooltotal": "3540529446912",
"poolused": "2466384969728"
}
Error:
scheduler caught exception:
undefined method `[]' for nil:NilClass
/home/toto/dashboard_v2/jobs/sample.rb:22:in `block in <top (required)>'
Export file json with powershell : "ASCII" not UTF 16
| ConvertTo-Json | Out-file d:\products\Dashing\json\process2.json -encoding ASCII
Send value to dashing
require 'json'
file = File.read('./process3.json')
counts = JSON.parse(file)
SCHEDULER.every '2s' do
synergy14 = counts["poolused"]
send_event('synergy3', { value: synergy14} )
end