mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-18 12:30:59 +03:00
Remove TLObject.to_json
This commit is contained in:
parent
b566e59036
commit
dbe66bf805
|
@ -589,6 +589,14 @@ broken for some time now (see `issue #1319 <https://github.com/LonamiWebs/Teleth
|
|||
anyway, so until there's a working solution, the mode is not supported. Pull Requests are welcome!
|
||||
|
||||
|
||||
The to_json method on objects has been removed
|
||||
----------------------------------------------
|
||||
|
||||
This was not very useful, as most of the time, you'll probably be having other data along with the
|
||||
object's JSON. It simply saved you an import (and not even always, in case you wanted another
|
||||
encoder). Use ``json.dumps(obj.to_dict())`` instead.
|
||||
|
||||
|
||||
The Conversation API has been removed
|
||||
-------------------------------------
|
||||
|
||||
|
|
|
@ -125,23 +125,6 @@ class TLObject:
|
|||
|
||||
return res
|
||||
|
||||
def to_json(self, fp=None, default=_json_default, **kwargs):
|
||||
"""
|
||||
Represent the current `TLObject` as JSON.
|
||||
|
||||
If ``fp`` is given, the JSON will be dumped to said
|
||||
file pointer, otherwise a JSON string will be returned.
|
||||
|
||||
Note that bytes and datetimes cannot be represented
|
||||
in JSON, so if those are found, they will be base64
|
||||
encoded and ISO-formatted, respectively, by default.
|
||||
"""
|
||||
d = self.to_dict()
|
||||
if fp:
|
||||
return json.dump(d, fp, default=default, **kwargs)
|
||||
else:
|
||||
return json.dumps(d, default=default, **kwargs)
|
||||
|
||||
def __bytes__(self):
|
||||
try:
|
||||
return self._bytes()
|
||||
|
|
Loading…
Reference in New Issue
Block a user