JsonHelper

JSON processing utilities

#include <JsonHelper.h>

Static Public Member Functions

static DynamicJsonDocument parseJson (const String &payload)
 
static DynamicJsonDocument decodeResponse (const String &payload)
 
static bool isValidJson (const DynamicJsonDocument &doc)
 
static String getString (const DynamicJsonDocument &doc, const char *key, const String &defaultValue="")
 
static int getInt (const DynamicJsonDocument &doc, const char *key, int defaultValue=0)
 
static bool getBool (const DynamicJsonDocument &doc, const char *key, bool defaultValue=false)
 

Member Function Documentation

◆ decodeResponse()

static DynamicJsonDocument CloudMouse::Utils::JsonHelper::decodeResponse ( const String &  payload)
inlinestatic

Parse HTTP response JSON payload Legacy method name for backward compatibility

Parameters
payloadHTTP response body containing JSON
Returns
DynamicJsonDocument containing parsed data

◆ getBool()

static bool CloudMouse::Utils::JsonHelper::getBool ( const DynamicJsonDocument &  doc,
const char *  key,
bool  defaultValue = false 
)
inlinestatic

Get boolean value from JSON with fallback

Parameters
docJSON document
keyKey to lookup
defaultValueDefault value if key not found
Returns
Boolean value or default

◆ getInt()

static int CloudMouse::Utils::JsonHelper::getInt ( const DynamicJsonDocument &  doc,
const char *  key,
int  defaultValue = 0 
)
inlinestatic

Get integer value from JSON with fallback

Parameters
docJSON document
keyKey to lookup
defaultValueDefault value if key not found
Returns
Integer value or default

◆ getString()

static String CloudMouse::Utils::JsonHelper::getString ( const DynamicJsonDocument &  doc,
const char *  key,
const String &  defaultValue = "" 
)
inlinestatic

Get string value from JSON with fallback

Parameters
docJSON document
keyKey to lookup
defaultValueDefault value if key not found
Returns
String value or default

◆ isValidJson()

static bool CloudMouse::Utils::JsonHelper::isValidJson ( const DynamicJsonDocument &  doc)
inlinestatic

Check if JSON document is valid (not empty)

Parameters
docJSON document to validate
Returns
true if document contains valid data

◆ parseJson()

static DynamicJsonDocument CloudMouse::Utils::JsonHelper::parseJson ( const String &  payload)
inlinestatic

Parse JSON string into DynamicJsonDocument

Parameters
payloadJSON string to parse
Returns
DynamicJsonDocument containing parsed data, or empty document on error