This is used to handle arrays of things like timestamps, which we can't just load from JSON without doing additional work to convert the elements back into Python objects.
(value: bytes, converter: Callable)
| 258 | |
| 259 | |
| 260 | def convert_complex_array_out(value: bytes, converter: Callable): |
| 261 | """ |
| 262 | This is used to handle arrays of things like timestamps, which we can't |
| 263 | just load from JSON without doing additional work to convert the elements |
| 264 | back into Python objects. |
| 265 | """ |
| 266 | parsed = load_json(value.decode("utf8")) |
| 267 | |
| 268 | def convert_list(list_value: list): |
| 269 | output = [] |
| 270 | |
| 271 | for value in list_value: |
| 272 | if isinstance(value, list): |
| 273 | # For nested arrays |
| 274 | output.append(convert_list(value)) |
| 275 | elif isinstance(value, str): |
| 276 | output.append(converter(value)) |
| 277 | else: |
| 278 | output.append(value) |
| 279 | |
| 280 | return output |
| 281 | |
| 282 | if isinstance(parsed, list): |
| 283 | return convert_list(parsed) |
| 284 | else: |
| 285 | return parsed |
| 286 | |
| 287 | |
| 288 | @decode_to_string |
nothing calls this directly
no test coverage detected