zephyr/lib/utils
Christoph Winklhofer fc37c02eb1 json: improve parsing and serializing of 'float' and 'double'
Up to now, the handling of type float was offloaded to the users of the
JSON utility, with the token JSON_TOK_FLOAT.

Improve handling of floating point types and support the types 'float'
and 'double' in a built-in way so that they can be directly parsed to
and serialized from variables (of type float or double).

The types are serialized in the shortest representation, either as a
decimal number or in scientific notation:
  * float (with JSON_TOK_FLOAT_FP): encoded with maximal 9 digits
  * double (with JSON_TOK_DOUBLE_FP): encoded with maximal 16 digits
  * NaN, Infinity, -Infinity: encoded and decoded as:
    {"nan_val":NaN,"inf_pos":Infinity,"inf_neg":-Infinity}

Enable the floating point functionality with the Kconfig option:
  JSON_LIBRARY_FP_SUPPORT=y

It requires a libc implementation with support for floating point
functions: strtof(), strtod(), isnan() and isinf().

Fixes: #59412
Signed-off-by: Christoph Winklhofer <cj.winklhofer@gmail.com>
2025-04-09 22:05:14 +02:00
..
base64.c
bitarray.c
CMakeLists.txt lib: utils: add consistent overhead byte stuffing 2025-03-11 05:36:49 +01:00
cobs.c lib: utils: add consistent overhead byte stuffing 2025-03-11 05:36:49 +01:00
dec.c
hex.c
json.c json: improve parsing and serializing of 'float' and 'double' 2025-04-09 22:05:14 +02:00
Kconfig json: improve parsing and serializing of 'float' and 'double' 2025-04-09 22:05:14 +02:00
notify.c
onoff.c
rb.c
ring_buffer.c ring_buffer: shrink size of struct ring_buf 2025-03-11 08:59:05 +01:00
timeutil.c sys: timeutil: expose and use macro for base year 2024-08-29 11:38:28 +02:00
utf8.c
winstream.c