Skip to content

Commit dddb38e

Browse files
committed
Fix codegen for sparse collection JSON serialization
1 parent cd93e74 commit dddb38e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/ModelInternalMapOrListJsonize.vm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#if($template.currentShape.sparse)
2626
#set($key = "${template.lowerCaseVarName}Item.first")
2727
#set($value = "*${template.lowerCaseVarName}Item.second${CppViewHelper.computeJsonizeString($template.currentShape.mapValue.shape)}")
28+
#if($template.currentShape.mapValue.shape.isStructure() || $template.currentShape.mapValue.shape.isTimeStamp() || $template.currentShape.mapValue.shape.isDocument())
29+
#set($value = "${template.lowerCaseVarName}Item.second${CppViewHelper.computeJsonizeString($template.currentShape.mapValue.shape, true)}")
30+
#end
2831
#if($template.currentShape.mapValue.shape.isBlob())
2932
#set($value = "HashingUtils::Base64Encode(*${template.lowerCaseVarName}Item.second${CppViewHelper.computeJsonizeString($template.currentShape.mapValue.shape)})")
3033
#end
@@ -86,7 +89,6 @@
8689
#if($template.currentShape.sparse)
8790
${template.currentSpaces} if(!${template.containerVar}[${template.lowerCaseVarName}Index].has_value())
8891
${template.currentSpaces} {
89-
${template.currentSpaces} ${template.lowerCaseVarName}JsonList[${template.lowerCaseVarName}Index].AsNull();
9092
${template.currentSpaces} continue;
9193
${template.currentSpaces} }
9294
#end
@@ -107,7 +109,11 @@
107109
#end
108110
#else
109111
#if($template.currentShape.sparse)
112+
#if($template.currentShape.listMember.shape.isStructure() || $template.currentShape.listMember.shape.isTimeStamp() || $template.currentShape.listMember.shape.isDocument())
113+
${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)});
114+
#else
110115
${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)});
116+
#end
111117
#else
112118
${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)});
113119
#end

0 commit comments

Comments
 (0)