zephyr/tests/lib
Christoph Winklhofer a5e295c452 json: improve parsing and serializing of integers
Add support for parsing and serializing of following integer types:
'int8_t', 'uint8_t', 'int16_t', 'uint16_t' and 'uint32_t'.

The generic integer token JSON_TOK_INT and JSON_TOK_UINT, in combination
with the field size (set by JSON_OBJ_DESCR_PRIM) allows to parse different
integer types, for example:

struct foo {
  int64_t i64;
  uint32_t u32;
  int16_t i16;
  uint8_t u8;
};

struct json_obj_descr foo_descr[] = {
  JSON_OBJ_DESCR_PRIM(struct foo, i64, JSON_TOK_INT),
  JSON_OBJ_DESCR_PRIM(struct foo, u32, JSON_TOK_UINT),
  JSON_OBJ_DESCR_PRIM(struct foo, i16, JSON_TOK_INT),
  JSON_OBJ_DESCR_PRIM(struct foo, u8, JSON_TOK_UINT),
};

These tokens also support parsing and serializing enums:

enum unsigned_enum { UA=0, UB=1, UC=2 };
enum signed_enum { SA=-1, SB=0, SC=1 };

struct foo {
  enum unsigned_enum u;
  enum signed_enum s;
};

struct json_obj_descr foo_descr[] = {
  JSON_OBJ_DESCR_PRIM(struct foo, u, JSON_TOK_UINT),
  JSON_OBJ_DESCR_PRIM(struct foo, s, JSON_TOK_INT),
};

Signed-off-by: Christoph Winklhofer <cj.winklhofer@gmail.com>
2025-04-11 06:32:50 +02:00
..
acpi
c_lib everywhere: Replace diagnostic pragmas with TOOLCHAIN_* macros 2025-03-20 21:57:47 +01:00
cbprintf_fp
cbprintf_package tests: lib: cbprintf_package: Extend test coverage 2024-11-01 09:56:03 -05:00
cmsis_dsp tests: unskip some tests 2025-03-28 21:52:13 +01:00
cmsis_nn tests: cmsis-nn: update tests for v7.0.0 2025-02-13 06:39:17 +01:00
cobs tests: utils: lib: cobs tests 2025-03-11 05:36:49 +01:00
cpp kscan: drop kscan and any reference 2025-03-13 16:56:26 +00:00
devicetree device: introduce struct device_ops 2025-03-10 21:32:40 +01:00
fdtable
gui/lvgl tests: Introduce greyscale-related tests modifications 2025-03-12 14:05:14 +00:00
hash_function
hash_map
heap boards: rename qemu_xtensa to qemu_xtensa/dc233c 2024-10-02 09:58:36 +02:00
heap_align tests/lib/heap_align: improve test some more 2025-03-17 02:21:27 +01:00
json json: improve parsing and serializing of integers 2025-04-11 06:32:50 +02:00
linear_range
lockfree
math/interpolation tests: fix various test ids and use existing scheme 2025-04-07 11:22:36 +02:00
mem_alloc everywhere: Use correct macro for gcc-specific warnings 2025-03-20 21:57:47 +01:00
mem_blocks
mem_blocks_stats
mpsc_pbuf boards native_posix: Remove twister support 2025-03-07 19:16:14 +01:00
multi_heap tests: lib: multi_heap: fix stack overflow 2025-03-12 07:15:12 +01:00
net_buf
newlib
notify
onoff
p4workq kernel: rename 'dumb' scheduler and simply call it 'simple' 2025-03-15 00:34:58 +01:00
ringbuffer ring_buffer: shrink size of struct ring_buf 2025-03-11 08:59:05 +01:00
shared_multi_heap
smf tests: lib: smf: Add missing equals 2025-01-20 16:27:10 +01:00
sprintf everywhere: Use correct macro for gcc-specific warnings 2025-03-20 21:57:47 +01:00
spsc_pbuf
sys_util
time boards native_posix: Remove twister support 2025-03-07 19:16:14 +01:00