@@ -158,6 +158,52 @@ namespace <#= this.Config.Namespace #>.Model.Internal.MarshallTransformat
158
158
}
159
159
else if(structure.IsMap)
160
160
{
161
+ ProcessMap(level, variableName, structure);
162
+ }
163
+ else if(structure.IsDocument)
164
+ {
165
+ #>
166
+ <#=new string(' ', level * 4)#> Amazon.Runtime.Documents.Internal.Transform.DocumentMarshaller.Instance.Write(context.Writer, <#=variableName#>);
167
+ <#+
168
+
169
+ }
170
+ else if(structure.IsStructure)
171
+ {
172
+ #>
173
+ <#=new string(' ', level * 4)#> context.Writer.WriteStartObject();
174
+
175
+ <#=new string(' ', level * 4)#> var marshaller = <#=structure.Name#>Marshaller.Instance;
176
+ <#=new string(' ', level * 4)#> marshaller.Marshall(<#=variableName#>, context);
177
+
178
+ <#=new string(' ', level * 4)#> context.Writer.WriteEndObject();
179
+ <#+
180
+ }
181
+ else if(structure.IsMemoryStream)
182
+ {
183
+ #>
184
+ <#=new string(' ', level * 4)#> context.Writer.WriteStringValue(StringUtils.FromMemoryStream(<#=variableName#>));
185
+ <#+
186
+ }
187
+ else
188
+ {
189
+ // Only use timestamp format based marshalling if format is not Unix epoch, which is the default for json/rest-json
190
+ if(structure.IsTimeStamp && structure.GetTimestampFormat(MarshallLocation.Body) != TimestampFormat.UnixTimestamp)
191
+ {
192
+ #>
193
+ <#=new string(' ', level * 4)#> context.Writer.WriteStringValue(<#=structure.PrimitiveMarshaller(MarshallLocation.Body)#>(<#=variableName#>));
194
+ <#+
195
+ }
196
+ else
197
+ {
198
+ DetermineNormalJsonWriteMethod(structure, variableName, level);
199
+ }
200
+
201
+ }
202
+ }
203
+
204
+ protected void ProcessMap(int level, string variableName, Shape structure)
205
+ {
206
+ string flatVariableName = variableName.Replace(".", "");
161
207
#>
162
208
<#=new string(' ', level * 4)#> context.Writer.WriteStartObject();
163
209
<#=new string(' ', level * 4)#> foreach (var <#=flatVariableName#>Kvp in <#=variableName#>)
@@ -177,7 +223,7 @@ namespace <#= this.Config.Namespace #>.Model.Internal.MarshallTransformat
177
223
if (isNullableMap)
178
224
{
179
225
#>
180
- <#=new string(' ', level * 4)#> if(<#=flatVariableName#>Value == null)
226
+ <#=new string(' ', level * 4)#> if (<#=flatVariableName#>Value == null)
181
227
<#=new string(' ', level * 4)#> {
182
228
<#=new string(' ', level * 4)#> context.Writer.WriteNullValue();
183
229
<#=new string(' ', level * 4)#> }
@@ -216,6 +262,39 @@ namespace <#= this.Config.Namespace #>.Model.Internal.MarshallTransformat
216
262
<#+
217
263
}
218
264
}
265
+ else if(structure.ValueShape.IsTimeStamp)
266
+ {
267
+ if(isNullableMap)
268
+ {
269
+ if (structure.ValueShape.data[Shape.TimestampFormatKey] != null && !string.Equals(structure.ValueShape.data["timestampFormat"].ToString(), "unixTimestamp"))
270
+ {
271
+ #>
272
+ <#=new string(' ', level * 4)#> context.Writer.WriteStringValue(<#=flatVariableName#>Value.Value);
273
+ <#+
274
+ }
275
+ else
276
+ {
277
+ #>
278
+ <#=new string(' ', level * 4)#> context.Writer.WriteNumberValue(Convert.ToInt64(StringUtils.FromDateTimeToUnixTimestamp(<#=flatVariableName#>Value.Value)));
279
+ <#+
280
+ }
281
+ }
282
+ else
283
+ {
284
+ if (structure.ValueShape.data[Shape.TimestampFormatKey] != null && !string.Equals(structure.ValueShape.data["timestampFormat"].ToString(), "unixTimestamp"))
285
+ {
286
+ #>
287
+ <#=new string(' ', level * 4)#> context.Writer.WriteStringValue(<#=flatVariableName#>Value);
288
+ <#+
289
+ }
290
+ else
291
+ {
292
+ #>
293
+ <#=new string(' ', level * 4)#> context.Writer.WriteNumberValue(Convert.ToInt64(StringUtils.FromDateTimeToUnixTimestamp(<#=flatVariableName#>Value)));
294
+ <#+
295
+ }
296
+ }
297
+ }
219
298
else
220
299
{
221
300
if(isNullableMap)
@@ -239,66 +318,8 @@ namespace <#= this.Config.Namespace #>.Model.Internal.MarshallTransformat
239
318
<#=new string(' ', level * 4)#> }
240
319
<#=new string(' ', level * 4)#> context.Writer.WriteEndObject();
241
320
<#+
242
- }
243
- else if(structure.IsDocument)
244
- {
245
- #>
246
- <#=new string(' ', level * 4)#> Amazon.Runtime.Documents.Internal.Transform.DocumentMarshaller.Instance.Write(context.Writer, <#=variableName#>);
247
- <#+
248
-
249
- }
250
- else if(structure.IsStructure)
251
- {
252
- #>
253
- <#=new string(' ', level * 4)#> context.Writer.WriteStartObject();
254
-
255
- <#=new string(' ', level * 4)#> var marshaller = <#=structure.Name#>Marshaller.Instance;
256
- <#=new string(' ', level * 4)#> marshaller.Marshall(<#=variableName#>, context);
257
-
258
- <#=new string(' ', level * 4)#> context.Writer.WriteEndObject();
259
- <#+
260
- }
261
- else if(structure.IsMemoryStream)
262
- {
263
- #>
264
- <#=new string(' ', level * 4)#> context.Writer.WriteStringValue(StringUtils.FromMemoryStream(<#=variableName#>));
265
- <#+
266
- }
267
- else
268
- {
269
- // Only use timestamp format based marshalling if format is not Unix epoch, which is the default for json/rest-json
270
- if(structure.IsTimeStamp && structure.GetTimestampFormat(MarshallLocation.Body) != TimestampFormat.UnixTimestamp)
271
- {
272
- #>
273
- <#=new string(' ', level * 4)#> context.Writer.WriteStringValue(<#=structure.PrimitiveMarshaller(MarshallLocation.Body)#>(<#=variableName#>));
274
- <#+
275
- }
276
- else
277
- {
278
- DetermineNormalJsonWriteMethod(structure, variableName, level);
279
- }
280
-
281
- }
282
- }
283
- #>
284
- <#+
285
- protected void DetermineCustomMarshallerJsonWriteMethod(Member member, string memberProperty, int level)
286
- {
287
- if (String.Equals(member.CustomMarshallerTransformation,"Amazon.Util.AWSSDKUtils.ConvertToUnixEpochMilliseconds", StringComparison.OrdinalIgnoreCase))
288
- {
289
- #>
290
- <#=new string(' ', level * 4)#> context.Writer.WriteNumberValue(<#=member.CustomMarshallerTransformation#>(<#=memberProperty#>));
291
- <#+
292
- }
293
- else
294
- {
295
- #>
296
- <#=new string(' ', level * 4)#> context.Writer.WriteStringValue(<#=member.CustomMarshallerTransformation#>(<#=memberProperty#>));
297
- <#+
298
- }
299
321
}
300
- #>
301
- <#+
322
+
302
323
/// https://smithy.io/2.0/aws/protocols/aws-restjson1-protocol.html#json-shape-serialization
303
324
/// timestamps in json protocols use unixtimestamp if none is specified (by default)
304
325
protected void DetermineNormalJsonWriteMethod(Shape shape, string memberProperty, int level)
@@ -329,21 +350,10 @@ namespace <#= this.Config.Namespace #>.Model.Internal.MarshallTransformat
329
350
}
330
351
else if (shape.IsInt || shape.IsLong || shape.IsFloat || shape.IsDouble)
331
352
{
332
- // Handle integer enums with special care to support both nullable and non-nullable types
333
- if (memberProperty.EndsWith(".Value") && shape.IsInt)
334
- {
335
- // Already has .Value appended, use as is for nullable types
353
+ // Simple numeric value
336
354
#>
337
355
<#=new string(' ', level * 4)#> context.Writer.WriteNumberValue(<#=memberProperty#>);
338
356
<#+
339
- }
340
- else
341
- {
342
- // For non-nullable types, don't try to access .Value
343
- #>
344
- <#=new string(' ', level * 4)#> context.Writer.WriteNumberValue(<#=memberProperty#>);
345
- <#+
346
- }
347
357
}
348
358
else if (shape.IsBoolean)
349
359
{
0 commit comments