39 lines
729 B
Dart
39 lines
729 B
Dart
import 'dart:convert';
|
|
|
|
class ImMessage {
|
|
final String type;
|
|
final String from;
|
|
final String to;
|
|
final String content;
|
|
|
|
ImMessage({
|
|
required this.type,
|
|
required this.from,
|
|
required this.to,
|
|
required this.content,
|
|
});
|
|
|
|
factory ImMessage.fromJsonString(String json) {
|
|
return ImMessage.fromJson(jsonDecode(json));
|
|
}
|
|
|
|
factory ImMessage.fromJson(Map<String, dynamic> json) {
|
|
return ImMessage(
|
|
type: json['type'],
|
|
from: json['from'],
|
|
to: json['to'],
|
|
content: json['content'],
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'type': type,
|
|
'from': from,
|
|
'to': to,
|
|
'content': content,
|
|
};
|
|
|
|
String toJsonString() {
|
|
return jsonEncode(toJson());
|
|
}
|
|
} |