@@ -23,12 +23,31 @@ namespace AWS.Lambda.Powertools.Parameters.Internal.Transform;
2323/// </summary>
2424internal class JsonTransformer : ITransformer
2525{
26+ private readonly JsonSerializerOptions _options ;
27+
28+ /// <summary>
29+ /// Initializes a new instance of the <see cref="JsonTransformer"/> class.
30+ /// </summary>
31+ public JsonTransformer ( )
32+ {
33+ _options = new JsonSerializerOptions
34+ {
35+ PropertyNameCaseInsensitive = true
36+ } ;
37+ }
38+
2639 /// <summary>
2740 /// Deserialize a JSON value from a JSON string.
2841 /// </summary>
2942 /// <param name="value">JSON string.</param>
3043 /// <typeparam name="T">JSON value type.</typeparam>
3144 /// <returns>JSON value.</returns>
45+ #if NET6_0_OR_GREATER
46+ [ System . Diagnostics . CodeAnalysis . UnconditionalSuppressMessage ( "AOT" , "IL3050:RequiresDynamicCode" ,
47+ Justification = "Types are expected to be known at compile time" ) ]
48+ [ System . Diagnostics . CodeAnalysis . UnconditionalSuppressMessage ( "Trimming" , "IL2026:RequiresUnreferencedCode" ,
49+ Justification = "Types are expected to be preserved" ) ]
50+ #endif
3251 public T ? Transform < T > ( string value )
3352 {
3453 if ( typeof ( T ) == typeof ( string ) )
@@ -37,6 +56,6 @@ internal class JsonTransformer : ITransformer
3756 if ( string . IsNullOrWhiteSpace ( value ) )
3857 return default ;
3958
40- return JsonSerializer . Deserialize < T > ( value ) ;
59+ return JsonSerializer . Deserialize < T > ( value , _options ) ;
4160 }
4261}
0 commit comments