You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been thinking, since mastodon already uses json and mastodonpy objects close to hashmaps, it should be quite easy, but alas with my naive attempt I get:
>>> json.dump(status[1], file)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.11/json/__init__.py", line 179, in dump
for chunk in iterable:
File "/usr/lib/python3.11/json/encoder.py", line 432, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/usr/lib/python3.11/json/encoder.py", line 406, in _iterencode_dict
yield from chunks
File "/usr/lib/python3.11/json/encoder.py", line 439, in _iterencode
o = _default(o)
^^^^^^^^^^^
File "/usr/lib/python3.11/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type datetime is not JSON serializable
And when reading back I probably will run into issues, because, mastodonpy objects are like hashmaps but not pure hashmaps.
I know I can just store the ids and retrieve the toots from the server again. This would actually have the benefit of getting updated toots, eg when more replies have been added.
OTOH caching toots would be better for privacy. (Nobody can track when and how often a toot is displayed.) So I'd like to know, whether there is some way.
The text was updated successfully, but these errors were encountered:
In my own code, I use some custom hooks. I will try to add a mechanism for json <-> internal object conversion that doesn't lose data (which is more interesting now that there is a whole type system)
I have been thinking, since mastodon already uses json and mastodonpy objects close to hashmaps, it should be quite easy, but alas with my naive attempt I get:
And when reading back I probably will run into issues, because, mastodonpy objects are like hashmaps but not pure hashmaps.
I know I can just store the ids and retrieve the toots from the server again. This would actually have the benefit of getting updated toots, eg when more replies have been added.
OTOH caching toots would be better for privacy. (Nobody can track when and how often a toot is displayed.) So I'd like to know, whether there is some way.
The text was updated successfully, but these errors were encountered: