Convert UUID objects to strings when serializing to JSON.

This commit is contained in:
Fabio Manganiello 2023-03-02 21:58:26 +01:00
parent 15fadb93bb
commit 7be55e446f
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -7,6 +7,7 @@ import inspect
import json import json
import time import time
from typing import Union from typing import Union
from uuid import UUID
logger = logging.getLogger('platypush') logger = logging.getLogger('platypush')
@ -60,6 +61,9 @@ class Message:
if isinstance(obj, set): if isinstance(obj, set):
return list(obj) return list(obj)
if isinstance(obj, UUID):
return str(obj)
value = self.parse_numpy(obj) value = self.parse_numpy(obj)
if value is not None: if value is not None:
return value return value