json: support parsing and serializing of char arrays and integers (int8_t, uint8_t, etc.) #87580
+882
−133
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Support parsing and serializing of char arrays and integers
By extending the struct 'json_obj_descr' with an additional union member 'field' that stores the size of the struct field it is possible to serialize and parse char arrays, integers with different width and also enum types. Added three new tokens:
Strings with char arrays
Use the token JSON_TOK_STRING_BUF to parse and serialize a string for a char array, for example:
Integers of different width
Use the token JSON_TOK_INT or JSON_TOK_UINT to parse and serialize integers of different types - for example:
Parsing and serializing enums
Fixes: #65200