Hostle
February 23, 2024, 6:01pm
1
Is it possible to parse float or double values using blobmsg_get_.. ?
i'm trying to parse c02 readings from the following json
{"id":1,"stype":2,"c02":759.18218994140625}
I could send the values as strings and parse them that way, then convert back to float, but i would like to avoid unnecessary processing if possible.
jow
February 23, 2024, 6:33pm
2
Afair there’s no dedicated getters, the approach is to use a union of both a double and a int64_t to convert the data payload to a double value, see e.g. here:
Edit: there is a double getter:
https://lxr.openwrt.org/source/libubox/blobmsg.h#L338
Hostle
February 23, 2024, 8:03pm
3
ahh, I had a older version of libubox on my host ...the BLOBMSG_TYPE_DOUBLE was not defined, oddly enough the getter was ...
anyhow, updated and now its working like a champ
Thanks jow