-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Description
Due to the top-down .to_json() approach, all the double quotes get applied and escaped recursively. Example result of calling str(update), where update is for example bot.getUpdates()[0].
{"message": "{\"from\": \"{\\\"id\\\": 1234567890, \\\"first_name\\\": \\\"Somebody\\\", \\\"username\\\": \\\"somebody\\\"}\", \"chat\": \"{\\\"id\\\": 45858904, \\\"first_name\\\": \\\"Somebody\\\", \\\"username\\\": \\\"somebody\\\"}\", \"message_id\": 7, \"text\": \"s\", \"date\": 1437171749}", "update_id": 532670696}Proposed solution: Add datafy, to_data or to_dict method to each data container class that is called top-down instead and define to_json as:
def to_json(self):
return json.dumps(self.to_data())Edit: I would probably add this method in a new base class named telegram.DataContainer and make to_data abstract.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels