@@ -84,9 +84,23 @@ def prepare_field_value(self, field_name: str, field: FieldInfo, value: Any, val
84
84
The prepared value.
85
85
"""
86
86
if value is not None and (self .field_is_complex (field ) or value_is_complex ):
87
- return json . loads ( value )
87
+ return self . decode_complex_value ( field_name , field , value )
88
88
return value
89
89
90
+ def decode_complex_value (self , field_name : str , field : FieldInfo , value : Any ) -> Any :
91
+ """
92
+ Decode the value for a complex field
93
+
94
+ Args:
95
+ field_name: The field name.
96
+ field: The field.
97
+ value: The value of the field that has to be prepared.
98
+
99
+ Returns:
100
+ The decoded value for further preparation
101
+ """
102
+ return json .loads (value )
103
+
90
104
@abstractmethod
91
105
def __call__ (self ) -> dict [str , Any ]:
92
106
pass
@@ -414,7 +428,7 @@ def prepare_field_value(self, field_name: str, field: FieldInfo, value: Any, val
414
428
else :
415
429
# field is complex and there's a value, decode that as JSON, then add explode_env_vars
416
430
try :
417
- value = json . loads ( value )
431
+ value = self . decode_complex_value ( field_name , field , value )
418
432
except ValueError as e :
419
433
if not allow_parse_failure :
420
434
raise e
@@ -516,7 +530,7 @@ def explode_env_vars(self, field_name: str, field: FieldInfo, env_vars: Mapping[
516
530
is_complex , allow_json_failure = self ._field_is_complex (target_field )
517
531
if is_complex :
518
532
try :
519
- env_val = json . loads ( env_val )
533
+ env_val = self . decode_complex_value ( last_key , target_field , env_val )
520
534
except ValueError as e :
521
535
if not allow_json_failure :
522
536
raise e
0 commit comments