Merge branch 'main' into feature-minePage
This commit is contained in:
@ -5,7 +5,7 @@ class MessageSystemModel {
|
||||
int? cursor;
|
||||
int? type;
|
||||
String? title;
|
||||
Map? content;
|
||||
dynamic content;
|
||||
Source? source;
|
||||
String? timeAt;
|
||||
int? cardType;
|
||||
@ -45,7 +45,9 @@ class MessageSystemModel {
|
||||
cursor: jsons["cursor"],
|
||||
type: jsons["type"],
|
||||
title: jsons["title"],
|
||||
content: json.decode(jsons["content"]),
|
||||
content: isValidJson(jsons["content"])
|
||||
? json.decode(jsons["content"])
|
||||
: jsons["content"],
|
||||
source: Source.fromJson(jsons["source"]),
|
||||
timeAt: jsons["time_at"],
|
||||
cardType: jsons["card_type"],
|
||||
@ -75,3 +77,12 @@ class Source {
|
||||
logo: json["logo"],
|
||||
);
|
||||
}
|
||||
|
||||
bool isValidJson(String str) {
|
||||
try {
|
||||
json.decode(str);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -39,11 +39,11 @@ class ModelResult {
|
||||
ModelResult.fromJson(Map<String, dynamic> json) {
|
||||
resultType = json['result_type'];
|
||||
summary = json['summary'];
|
||||
outline = json['result_type'] == 2
|
||||
? json['outline']
|
||||
outline = json['result_type'] == 0
|
||||
? <OutlineItem>[]
|
||||
: json['outline']
|
||||
.map<OutlineItem>((e) => OutlineItem.fromJson(e))
|
||||
.toList()
|
||||
: <OutlineItem>[];
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user