diff --git a/src/aws-cpp-sdk-core/include/aws/core/utils/json/JsonSerializer.h b/src/aws-cpp-sdk-core/include/aws/core/utils/json/JsonSerializer.h index ae98f6c18ff..fabbe7aaf33 100644 --- a/src/aws-cpp-sdk-core/include/aws/core/utils/json/JsonSerializer.h +++ b/src/aws-cpp-sdk-core/include/aws/core/utils/json/JsonSerializer.h @@ -100,6 +100,11 @@ namespace Aws JsonValue& WithNull(const Aws::String& key); JsonValue& WithNull(const char* key); + /** + * Converts the current JSON node to null. + */ + JsonValue& AsNull(); + /** * Converts the current JSON node to a string. */ diff --git a/src/aws-cpp-sdk-core/source/utils/json/JsonSerializer.cpp b/src/aws-cpp-sdk-core/source/utils/json/JsonSerializer.cpp index bbf44e5b57d..25edf4363e9 100644 --- a/src/aws-cpp-sdk-core/source/utils/json/JsonSerializer.cpp +++ b/src/aws-cpp-sdk-core/source/utils/json/JsonSerializer.cpp @@ -170,6 +170,13 @@ JsonValue& JsonValue::WithNull(const Aws::String& key) return WithNull(key.c_str()); } +JsonValue& JsonValue::AsNull() +{ + Destroy(); + m_value = cJSON_AS4CPP_CreateNull(); + return *this; +} + JsonValue& JsonValue::AsString(const Aws::String& value) { Destroy(); diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/ModelInternalMapOrListJsonize.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/ModelInternalMapOrListJsonize.vm index 6b102baaae5..1a03e9e5ace 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/ModelInternalMapOrListJsonize.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/ModelInternalMapOrListJsonize.vm @@ -25,6 +25,9 @@ #if($template.currentShape.sparse) #set($key = "${template.lowerCaseVarName}Item.first") #set($value = "*${template.lowerCaseVarName}Item.second${CppViewHelper.computeJsonizeString($template.currentShape.mapValue.shape)}") +#if($template.currentShape.mapValue.shape.isStructure() || $template.currentShape.mapValue.shape.isTimeStamp() || $template.currentShape.mapValue.shape.isDocument()) +#set($value = "${template.lowerCaseVarName}Item.second${CppViewHelper.computeJsonizeString($template.currentShape.mapValue.shape, true)}") +#end #if($template.currentShape.mapValue.shape.isBlob()) #set($value = "HashingUtils::Base64Encode(*${template.lowerCaseVarName}Item.second${CppViewHelper.computeJsonizeString($template.currentShape.mapValue.shape)})") #end @@ -107,7 +110,11 @@ #end #else #if($template.currentShape.sparse) +#if($template.currentShape.listMember.shape.isStructure() || $template.currentShape.listMember.shape.isTimeStamp() || $template.currentShape.listMember.shape.isDocument()) + ${template.currentSpaces} ${template.lowerCaseVarName}JsonList[${template.lowerCaseVarName}Index].As${CppViewHelper.computeJsonCppType($template.currentShape.listMember.shape)}(${template.containerVar}[${template.lowerCaseVarName}Index]${CppViewHelper.computeJsonizeString($template.currentShape.listMember.shape, true)}); +#else ${template.currentSpaces} ${template.lowerCaseVarName}JsonList[${template.lowerCaseVarName}Index].As${CppViewHelper.computeJsonCppType($template.currentShape.listMember.shape)}(*${template.containerVar}[${template.lowerCaseVarName}Index]${CppViewHelper.computeJsonizeString($template.currentShape.listMember.shape)}); +#end #else ${template.currentSpaces} ${template.lowerCaseVarName}JsonList[${template.lowerCaseVarName}Index].As${CppViewHelper.computeJsonCppType($template.currentShape.listMember.shape)}(${template.containerVar}[${template.lowerCaseVarName}Index]${CppViewHelper.computeJsonizeString($template.currentShape.listMember.shape)}); #end