-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sending a SetChargeProfile call fails with TypeError #68
Comments
After a short research it seems we have 2 options:
|
OrangeTux
pushed a commit
that referenced
this issue
Feb 19, 2020
Version `0.6.0` forces validation of `Call`s before the are send to the other end. The validation of `call.SetChargingProfilePayload` fails with a TypeError. The charging profile contains a value of type `decimal.Decimal` and this value cannot be serialized to JSON. The problem can be demonstrated like this: >>> import decimal >>> import json >>> >>> json.dumps(decimal.Decimal(3)) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/developer/.pyenv/versions/3.7.0/lib/python3.7/json/__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "/home/developer/.pyenv/versions/3.7.0/lib/python3.7/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/home/developer/.pyenv/versions/3.7.0/lib/python3.7/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/home/developer/.pyenv/versions/3.7.0/lib/python3.7/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type Decimal is not JSON serializable This bug has been fixed by creating a custom enconder for `decimal.Decimal`. Fixes: #68
OrangeTux
added a commit
that referenced
this issue
Feb 19, 2020
Version `0.6.0` forces validation of `Call`s before the are send to the other end. The validation of `call.SetChargingProfilePayload` fails with a TypeError. The charging profile contains a value of type `decimal.Decimal` and this value cannot be serialized to JSON. The problem can be demonstrated like this: >>> import decimal >>> import json >>> >>> json.dumps(decimal.Decimal(3)) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/developer/.pyenv/versions/3.7.0/lib/python3.7/json/__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "/home/developer/.pyenv/versions/3.7.0/lib/python3.7/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/home/developer/.pyenv/versions/3.7.0/lib/python3.7/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/home/developer/.pyenv/versions/3.7.0/lib/python3.7/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type Decimal is not JSON serializable This bug has been fixed by creating a custom enconder for `decimal.Decimal`. Fixes: #68
ajmirsky
pushed a commit
to ajmirsky/ocpp
that referenced
this issue
Nov 26, 2024
Version `0.6.0` forces validation of `Call`s before the are send to the other end. The validation of `call.SetChargingProfilePayload` fails with a TypeError. The charging profile contains a value of type `decimal.Decimal` and this value cannot be serialized to JSON. The problem can be demonstrated like this: >>> import decimal >>> import json >>> >>> json.dumps(decimal.Decimal(3)) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/developer/.pyenv/versions/3.7.0/lib/python3.7/json/__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "/home/developer/.pyenv/versions/3.7.0/lib/python3.7/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/home/developer/.pyenv/versions/3.7.0/lib/python3.7/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/home/developer/.pyenv/versions/3.7.0/lib/python3.7/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type Decimal is not JSON serializable This bug has been fixed by creating a custom enconder for `decimal.Decimal`. Fixes: mobilityhouse#68
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version
0.6.0
forces validation ofCall
s before the are send to the other end. The validation ofcall.SetChargingProfilePayload
fails with a TypeError. The charging profile contains a value of typedecimal.Decimal
and this value cannot be serialized to JSON. The problem can be demonstrated like this:The text was updated successfully, but these errors were encountered: