From 14106571e7b4a001e01cbc5ec238f08f6a1353d3 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Wed, 7 Dec 2022 15:52:15 +0100 Subject: [PATCH] [chip-tool] Allow the string 'null' to be used for TypedComplexArgument of Nullable type (#23887) --- examples/chip-tool/commands/clusters/ComplexArgument.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/chip-tool/commands/clusters/ComplexArgument.h b/examples/chip-tool/commands/clusters/ComplexArgument.h index 8684116893cd12..8cb23a0b661797 100644 --- a/examples/chip-tool/commands/clusters/ComplexArgument.h +++ b/examples/chip-tool/commands/clusters/ComplexArgument.h @@ -29,7 +29,8 @@ #include "JsonParser.h" -constexpr uint8_t kMaxLabelLength = 100; +constexpr uint8_t kMaxLabelLength = 100; +constexpr const char kNullString[] = "null"; class ComplexArgumentParser { @@ -326,7 +327,11 @@ class TypedComplexArgument : public ComplexArgument CHIP_ERROR Parse(const char * label, const char * json) { Json::Value value; - if (!JsonParser::ParseComplexArgument(label, json, value)) + if (strcmp(kNullString, json) == 0) + { + value = Json::nullValue; + } + else if (!JsonParser::ParseComplexArgument(label, json, value)) { return CHIP_ERROR_INVALID_ARGUMENT; }