msg_bean_data_entity_helper.dart 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import 'package:bbyyy/beans/msg_bean_data_entity.dart';
  2. msgBeanDataEntityFromJson(MsgBeanDataEntity data, Map<String, dynamic> json) {
  3. if (json['sender_uid'] != null) {
  4. data.senderUid = json['sender_uid'] is String
  5. ? int.tryParse(json['sender_uid'])
  6. : json['sender_uid'].toInt();
  7. }
  8. if (json['sender_pic'] != null) {
  9. data.senderPic = json['sender_pic'].toString();
  10. }
  11. if (json['sender_name'] != null) {
  12. data.senderName = json['sender_name'].toString();
  13. }
  14. if (json['type'] != null) {
  15. data.type = json['type'].toString();
  16. }
  17. if (json['key'] != null) {
  18. data.key = json['key'].toString();
  19. }
  20. if (json['sent_at'] != null) {
  21. data.sentAt = json['sent_at'].toString();
  22. }
  23. if (json['content'] != null) {
  24. data.content = json['content'].toString();
  25. }
  26. if (json['uuid'] != null) {
  27. data.uuid = json['uuid'].toString();
  28. }
  29. return data;
  30. }
  31. Map<String, dynamic> msgBeanDataEntityToJson(MsgBeanDataEntity entity) {
  32. final Map<String, dynamic> data = new Map<String, dynamic>();
  33. data['sender_uid'] = entity.senderUid;
  34. data['sender_pic'] = entity.senderPic;
  35. data['sender_name'] = entity.senderName;
  36. data['type'] = entity.type;
  37. data['key'] = entity.key;
  38. data['sent_at'] = entity.sentAt;
  39. data['content'] = entity.content;
  40. data['uuid'] = entity.uuid;
  41. return data;
  42. }