Converting JSON String to Number


I’m sending data as a string (I can’t change this), but it’s really a number.
"body": { "event": "structure_blank_A0", "data": "930" }

I have the Virtual Device attribute set as a Number (not a string) and I see that it is converting it as far as I can tell:
{ "data": 930 }
^This is from the device window.

But when I attempt to plot it on my dashboard as a time series graph, it’s stuck at zero. I’m getting the correct data in the Gauge block, so I know it’s receiving my data.

Is there a way to convert the data in my workflow? Or a bug or some other issue that isn’t letting me plot the data? Thanks!



Hey Dillon, what’s your dashboard ID that has the time series graph? It’ll be in your URL /dashboards/:id. Dashboard IDs aren’t sensitive, so don’t worry about pasting it in here.





All the data is being stored correctly as numbers. We’re digging in to find underlying cause of the graph issue.



Found the underlying cause. It was due to the data type of the attribute being changed from string to number. We are releasing a fix shortly. In the meantime, a workaround is to remove the reading attribute, add an attribute of a different name, and switch the implementation to use the new attribute. Sorry for the inconvenience!



On a related note, Structure does attempt to automatically cast the incoming data to the type specified on the attribute. So if you use an attribute of type Number and report a string, it will be cast to a number automatically.



The fix has been pushed, and it now looks like your graph is working. Sorry again!

1 Like


No problem. Thanks for checking it out!