JSON Utilities
JSON Utilities
Section titled “JSON Utilities”Path: src/utils/json_utils.h
Revision History:
- Initial documentation
A collection of inline utility functions for parsing JSON data in embedded applications. These functions provide a consistent way to extract values from JSON objects, with built-in type validation and error reporting.
REQUIREMENTS
Section titled “REQUIREMENTS”- ArduinoJson library
- ArduinoLog library
PROVIDES
Section titled “PROVIDES”JsonUtils
namespace containing utility functions:parseJsonFieldUint32
: Parses a 32-bit unsigned integer from JSONparseJsonFieldUint8
: Parses an 8-bit unsigned integer from JSONparseJsonFieldBool
: Parses a boolean value from JSON
FEATURES
Section titled “FEATURES”- Type validation for JSON field parsing
- Maintains default values when fields are missing or of incorrect type
- Debug logging for parsing errors
- Consistent parsing interface across different data types
DEPENDENCIES
Section titled “DEPENDENCIES”BEHAVIOUR
Section titled “BEHAVIOUR”PERFORMANCE
Section titled “PERFORMANCE”- Consider providing batch parsing functions to reduce parsing overhead for multiple fields
- Evaluate memory usage when parsing large JSON objects
SECURITY
Section titled “SECURITY”- Currently no validation for value ranges; consider adding range validation options
- Implement protection against malformed JSON that could lead to buffer overflows
COMPLIANCE
Section titled “COMPLIANCE”- Ensure all error messages follow consistent formatting standards
- Consider adding more documentation for compliance with project coding standards
RECOMMENDATIONS
Section titled “RECOMMENDATIONS”- Add support for additional data types (e.g., float, string)
- Consider a more structured approach to error handling (e.g., error codes or exceptions)
- Add functions for array parsing and nested object traversal
- Provide examples of common JSON parsing scenarios