pocketbase
pocketbase copied to clipboard
add json serialization support for various types
Great work on this SDK.
This is a request for an enhancement to support JSON serialization for the different types supported
Eg:
import json
from pocketbase import PocketBase
client = PocketBase('http://127.0.0.1:8090')
# authenticate as regular user
user_data = client.collection("users").auth_with_password("[email protected]", "thisIsAFaksePassword123")
# get a compliance report
report = client.collection("compliance").get_list()
print(json.dumps(report, indent=4))
This currently results in:
Traceback (most recent call last):
File "/Users/dansikes/go/src/github.com/dsikes/equip/scripts/test.py", line 12, in <module>
print(json.dumps(report, indent=4))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 202, in encode
chunks = list(chunks)
^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 439, in _iterencode
o = _default(o)
^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type ListResult is not JSON serializable
Happy to work on a PR, but wanted to see if this was something you'd consider before doing so.
Thanks!
@dslikes I think it would be really nice to have it! Please fell free to submit a PR and I will get it verified asap.
Thanks!
Would absolutely love to have this feature!!
Please reopen, the solution was reverted by https://github.com/vaphes/pocketbase/pull/42. This is still very much needed.