Can someone explain how does the JSON_OBJECT type works for a device driver command?
It's probably easier to show what I'm doing.. in the driver code there's a method, setLocation, that takes a JSON_OBJECT
command('setLocation', [[name: 'Set Location', type: 'JSON_OBJECT', description: 'blah..']])
Then, in the command definition I'm logging the value and type:
def setLocation (loc) {
log.info "Location received ${loc}"
log.info "TYPE: ${loc.class}"
I entered the following in the driver page: {"lat": 80}
and here's what's logged:
Location received {"lat": 80}
TYPE: class java.lang.String
I was expecting the variable to be a JSON object -- meaning I could reference loc.lat
but as you can see it's a String. Am I missing something? I imagine I could just take in a String and convert it to JSON but was thinking the JSON_OBJECT
would do that for me somehow
thanks,
joe