mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Allow serializing integer valued enums in JSON config dicts
This commit is contained in:
parent
9a0ee46c80
commit
cb975976c1
@ -56,6 +56,9 @@ def to_json(obj):
|
||||
if hasattr(obj, 'toBase64'): # QByteArray
|
||||
return {'__class__': 'bytearray',
|
||||
'__value__': bytes(obj.toBase64()).decode('ascii')}
|
||||
v = getattr(obj, 'value', None)
|
||||
if isinstance(v, int): # Possibly an enum with integer values like all the Qt enums
|
||||
return v
|
||||
raise TypeError(repr(obj) + ' is not JSON serializable')
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user