Skip to content

Commit c935440

Browse files
committed
refactor: infer uuid
1 parent 615e9fc commit c935440

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/serializers/infer.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,11 @@ pub(crate) fn infer_json_key_known<'py>(ob_type: &ObType, key: &'py PyAny, extra
587587
let iso_time = super::type_serializers::datetime_etc::time_to_string(py_time)?;
588588
Ok(Cow::Owned(iso_time))
589589
}
590+
ObType::Uuid => {
591+
let py_uuid: &PyAny = key.downcast()?;
592+
let uuid = super::type_serializers::uuid::uuid_to_string(py_uuid)?;
593+
Ok(Cow::Owned(uuid))
594+
}
590595
ObType::Timedelta => {
591596
let py_timedelta: &PyDelta = key.downcast()?;
592597
extra.config.timedelta_mode.json_key(py_timedelta)
@@ -619,7 +624,7 @@ pub(crate) fn infer_json_key_known<'py>(ob_type: &ObType, key: &'py PyAny, extra
619624
let k = key.getattr(intern!(key.py(), "value"))?;
620625
infer_json_key(k, extra)
621626
}
622-
ObType::Path | ObType::Uuid => Ok(key.str()?.to_string_lossy()),
627+
ObType::Path => Ok(key.str()?.to_string_lossy()),
623628
ObType::Unknown => {
624629
if let Some(fallback) = extra.fallback {
625630
let next_key = fallback.call1((key,))?;

0 commit comments

Comments
 (0)