Traceback (most recent call last):
File "testing-ground/decimal_jsons_test.py", line 19, in <module>
a = jsons.load(dictionary, Something)
File "testing-ground/env/lib/python3.10/site-packages/jsons/_load_impl.py", line 101, in load
return _do_load(json_obj, deserializer, cls, initial, **kwargs_)
File "testing-ground/env/lib/python3.10/site-packages/jsons/_load_impl.py", line 113, in _do_load
result = deserializer(json_obj, cls, **kwargs)
File "testing-ground/env/lib/python3.10/site-packages/jsons/deserializers/default_object.py", line 40, in default_object_deserializer
constructor_args = _get_constructor_args(obj, cls, **kwargs)
File "testing-ground/env/lib/python3.10/site-packages/jsons/deserializers/default_object.py", line 64, in _get_constructor_args
key, value = _get_value_for_attr(obj=obj,
File "testing-ground/env/lib/python3.10/site-packages/jsons/deserializers/default_object.py", line 94, in _get_value_for_attr
result = sig_key, _get_value_from_obj(obj, cls, sig, sig_key,
File "testing-ground/env/lib/python3.10/site-packages/jsons/deserializers/default_object.py", line 140, in _get_value_from_obj
value = load(obj[sig_key], cls_, meta_hints=new_hints, **kwargs)
File "testing-ground/env/lib/python3.10/site-packages/jsons/_load_impl.py", line 83, in load
cls, meta_hints = _check_and_get_cls_and_meta_hints(
File "testing-ground/env/lib/python3.10/site-packages/jsons/_load_impl.py", line 200, in _check_and_get_cls_and_meta_hints
raise DeserializationError(msg, json_obj, cls)
jsons.exceptions.DeserializationError: Invalid type: "decimal.Decimal", only arguments of the following types are allowed: str, int, float, bool, list, tuple, set, dict, NoneType
But JSONS is capable of deserializing this dictionary just fine, we just need to modify the list of types it is supposed to be able to deserialize, here, we just need to add decimal.Decimal to the list of VALID_TYPES
Hey there,
When "deserializating" a dictionary that contains a
decimal.Decimalfield, to a class that accepts that field as anintor afloat, JSONS is throwing an exception:But JSONS is capable of deserializing this dictionary just fine, we just need to modify the list of types it is supposed to be able to deserialize, here, we just need to add
decimal.Decimalto the list ofVALID_TYPESFor this code:
Observed behavior:
Jsons throws the above exception
Expected behavior:
a.valueis initialized to15.0Thanks