JSON basic support for Float values #77665
Replies: 3 comments
-
Given that Zephyr is used on many IOT devices it seems crazy there is no json float support. If JSON_TOK_FLOAT is used the required strtod and friends are not available then just I've been using ArduinoJson as I'm already familiar with it, |
Beta Was this translation helpful? Give feedback.
-
If you have a patch for this, just create a PR to get feedback. |
Beta Was this translation helpful? Give feedback.
-
Following that discussion as I also need this feature. @jcontrerasf Are you going to submit a PR ? |
Beta Was this translation helpful? Give feedback.
-
A few days ago, I needed to consume an API and realized that Zephyr's JSON utility doesn't support float parsing. It actually processes them as opaque values. That's why I decided to implement this feature myself, and I'd like to know if it's suitable/secure enough to be officially added to Zephyr.
This implementation is quite limited; it only supports one decimal place. However, in my opinion, this is much better than just returning 0.
The changes in
json.c
are as follows: (1) adding a separatecase JSON_TOK_FLOAT
in thedecode_value
function and (2) returning the correctsizeof(float)
inget_elem_size()
.Beta Was this translation helpful? Give feedback.
All reactions