@@ -23,12 +23,31 @@ namespace AWS.Lambda.Powertools.Parameters.Internal.Transform;
23
23
/// </summary>
24
24
internal class JsonTransformer : ITransformer
25
25
{
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
+
26
39
/// <summary>
27
40
/// Deserialize a JSON value from a JSON string.
28
41
/// </summary>
29
42
/// <param name="value">JSON string.</param>
30
43
/// <typeparam name="T">JSON value type.</typeparam>
31
44
/// <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
32
51
public T ? Transform < T > ( string value )
33
52
{
34
53
if ( typeof ( T ) == typeof ( string ) )
@@ -37,6 +56,6 @@ internal class JsonTransformer : ITransformer
37
56
if ( string . IsNullOrWhiteSpace ( value ) )
38
57
return default ;
39
58
40
- return JsonSerializer . Deserialize < T > ( value ) ;
59
+ return JsonSerializer . Deserialize < T > ( value , _options ) ;
41
60
}
42
61
}
0 commit comments