ivk1800 / tdlib-dart

MIT License
19 stars 12 forks source link

inconsistent conversion #5

Closed AndrewTran2018 closed 1 year ago

AndrewTran2018 commented 1 year ago

at some places, I guess it is intentionally systematic, toJson and fromJson make inconsistent conversion. for example: final int mediaAlbumId;

Message.toJson(){ .. 'media_album_id': 'mediaAlbumId, }

while in Message.fromJson(){ mediaAlbumId: int.tryParse(json['media_album_id']) ?? 0, }

when people use Message.toJson to output a map, later they use dart:covert: json.encode(map) to store the json as a jsonblob string.

And then they come back to use json:decode(jsonblob string) and apply Message.fromJson, now that it is totally broken.

@ivk1800

ivk1800 commented 1 year ago

Fixed https://github.com/ivk1800/tdlib-dart/commit/c54a942a65bd734755659a91964c2b0ad90d6cf2