@@ -117,9 +117,11 @@ def _encode_value(value: Any, level: int, opts: EncoderOptions) -> str:
117117 return _encode_array (value , level , opts )
118118 elif isinstance (value , dict ):
119119 return _encode_object (value , level , opts )
120+ elif isinstance (value , tuple ):
121+ return _encode_tuple (value )
120122 else :
121- # Handle other types as null
122- return 'null'
123+ # Handle other types with NotImplementedError
124+ raise NotImplementedError ( f'Encoding for type { type ( value ) } is not implemented.' )
123125
124126
125127def _encode_object (obj : dict , level : int , opts : EncoderOptions ) -> str :
@@ -177,6 +179,16 @@ def _encode_array(arr: list, level: int, opts: EncoderOptions) -> str:
177179 # Mixed array (list format)
178180 return _encode_list_array (arr , level , opts , key = None )
179181
182+ def _encode_tuple (value : tuple ) -> str :
183+ """Encode a tuple."""
184+ if not value :
185+ return '[]'
186+
187+ tuple_data = ',' .join (_encode_primitive_value (v ) for v in value )
188+ tuple_string = f'[{ tuple_data } ]'
189+
190+ return tuple_string
191+
180192
181193def _encode_array_with_key (key : str , arr : list , level : int , opts : EncoderOptions ) -> str :
182194 """Encode an array with its key prefix for object context."""
0 commit comments