Skip to content

Commit

Permalink
[chip-tool] Allow the string 'null' to be used for TypedComplexArgume…
Browse files Browse the repository at this point in the history
…nt of Nullable type
  • Loading branch information
vivien-apple committed Dec 2, 2022
1 parent 5529d74 commit f909f2a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions examples/chip-tool/commands/clusters/ComplexArgument.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@

#include "JsonParser.h"

constexpr uint8_t kMaxLabelLength = 100;
constexpr uint8_t kMaxLabelLength = 100;
constexpr const char kNullString[] = "null";
constexpr const char kNullStringLen = ArraySize(kNullString) - 1 /* ignore \0 */;

class ComplexArgumentParser
{
Expand Down Expand Up @@ -326,7 +328,11 @@ class TypedComplexArgument : public ComplexArgument
CHIP_ERROR Parse(const char * label, const char * json)
{
Json::Value value;
if (!JsonParser::ParseComplexArgument(label, json, value))
if (strncmp(kNullString, json, kNullStringLen) == 0 && strlen(json) == kNullStringLen)
{
value = Json::nullValue;
}
else if (!JsonParser::ParseComplexArgument(label, json, value))
{
return CHIP_ERROR_INVALID_ARGUMENT;
}
Expand Down

0 comments on commit f909f2a

Please sign in to comment.