Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and lazarkov committed Aug 8, 2024
1 parent d3d6e73 commit 360a102
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions examples/tv-app/android/java/ContentAppCommandDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ bool isValidJson(const char * response)
Json::Value value;
std::unique_ptr<Json::CharReader> testReader(readerBuilder.newCharReader());

if (!testReader->parse(response, response + std::strlen(response), &value, &errors)) {
if (!testReader->parse(response, response + std::strlen(response), &value, &errors))
{
ChipLogError(Zcl, "Failed to parse JSON: %s\n", errors.c_str());
return false;
}

// Validate and access JSON data safely
if (!value.isObject()) {
if (!value.isObject())
{
ChipLogError(Zcl, "Invalid JSON structure: not an object");
return false;
}
Expand Down Expand Up @@ -123,13 +125,15 @@ void ContentAppCommandDelegate::InvokeCommand(CommandHandlerInterface::HandlerCo
{
JniUtfString respStr(env, resp);
ChipLogProgress(Zcl, "ContentAppCommandDelegate::InvokeCommand got response %s", respStr.c_str());
if (isValidJson(respStr.c_str())) {
if (isValidJson(respStr.c_str()))
{
FormatResponseData(handlerContext, respStr.c_str());
} else {
}
else
{
// return dummy value in case JSON is invalid
FormatResponseData(handlerContext, "{\"value\":{}}");
}

}
env->DeleteLocalRef(resp);
}
Expand Down

0 comments on commit 360a102

Please sign in to comment.