fromJson static method
Returns a new ModerationAPIComment instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static ModerationAPIComment? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
assert(json.containsKey(r'_id'), 'Required key "ModerationAPIComment[_id]" is missing from JSON.');
assert(json[r'_id'] != null, 'Required key "ModerationAPIComment[_id]" has a null value in JSON.');
assert(json.containsKey(r'tenantId'), 'Required key "ModerationAPIComment[tenantId]" is missing from JSON.');
assert(json[r'tenantId'] != null, 'Required key "ModerationAPIComment[tenantId]" has a null value in JSON.');
assert(json.containsKey(r'urlId'), 'Required key "ModerationAPIComment[urlId]" is missing from JSON.');
assert(json[r'urlId'] != null, 'Required key "ModerationAPIComment[urlId]" has a null value in JSON.');
assert(json.containsKey(r'url'), 'Required key "ModerationAPIComment[url]" is missing from JSON.');
assert(json[r'url'] != null, 'Required key "ModerationAPIComment[url]" has a null value in JSON.');
assert(json.containsKey(r'commenterName'), 'Required key "ModerationAPIComment[commenterName]" is missing from JSON.');
assert(json[r'commenterName'] != null, 'Required key "ModerationAPIComment[commenterName]" has a null value in JSON.');
assert(json.containsKey(r'commentHTML'), 'Required key "ModerationAPIComment[commentHTML]" is missing from JSON.');
assert(json[r'commentHTML'] != null, 'Required key "ModerationAPIComment[commentHTML]" has a null value in JSON.');
assert(json.containsKey(r'date'), 'Required key "ModerationAPIComment[date]" is missing from JSON.');
assert(json.containsKey(r'approved'), 'Required key "ModerationAPIComment[approved]" is missing from JSON.');
assert(json[r'approved'] != null, 'Required key "ModerationAPIComment[approved]" has a null value in JSON.');
assert(json.containsKey(r'locale'), 'Required key "ModerationAPIComment[locale]" is missing from JSON.');
assert(json.containsKey(r'verified'), 'Required key "ModerationAPIComment[verified]" is missing from JSON.');
assert(json[r'verified'] != null, 'Required key "ModerationAPIComment[verified]" has a null value in JSON.');
return true;
}());
return ModerationAPIComment(
isLocalDeleted: mapValueOfType<bool>(json, r'isLocalDeleted'),
replyCount: mapValueOfType<double>(json, r'replyCount'),
feedbackResults: json[r'feedbackResults'] is Iterable
? (json[r'feedbackResults'] as Iterable).cast<String>().toList(growable: false)
: const [],
isVotedUp: mapValueOfType<bool>(json, r'isVotedUp'),
isVotedDown: mapValueOfType<bool>(json, r'isVotedDown'),
myVoteId: mapValueOfType<String>(json, r'myVoteId'),
id: mapValueOfType<String>(json, r'_id')!,
tenantId: mapValueOfType<String>(json, r'tenantId')!,
urlId: mapValueOfType<String>(json, r'urlId')!,
url: mapValueOfType<String>(json, r'url')!,
pageTitle: mapValueOfType<String>(json, r'pageTitle'),
userId: mapValueOfType<String>(json, r'userId'),
anonUserId: mapValueOfType<String>(json, r'anonUserId'),
commenterName: mapValueOfType<String>(json, r'commenterName')!,
commenterLink: mapValueOfType<String>(json, r'commenterLink'),
commentHTML: mapValueOfType<String>(json, r'commentHTML')!,
parentId: mapValueOfType<String>(json, r'parentId'),
date: mapDateTime(json, r'date', r''),
localDateString: mapValueOfType<String>(json, r'localDateString'),
votes: mapValueOfType<double>(json, r'votes'),
votesUp: mapValueOfType<double>(json, r'votesUp'),
votesDown: mapValueOfType<double>(json, r'votesDown'),
expireAt: mapDateTime(json, r'expireAt', r''),
reviewed: mapValueOfType<bool>(json, r'reviewed'),
avatarSrc: mapValueOfType<String>(json, r'avatarSrc'),
isSpam: mapValueOfType<bool>(json, r'isSpam'),
permNotSpam: mapValueOfType<bool>(json, r'permNotSpam'),
hasLinks: mapValueOfType<bool>(json, r'hasLinks'),
hasCode: mapValueOfType<bool>(json, r'hasCode'),
approved: mapValueOfType<bool>(json, r'approved')!,
locale: mapValueOfType<String>(json, r'locale'),
isBannedUser: mapValueOfType<bool>(json, r'isBannedUser'),
isByAdmin: mapValueOfType<bool>(json, r'isByAdmin'),
isByModerator: mapValueOfType<bool>(json, r'isByModerator'),
isPinned: mapValueOfType<bool>(json, r'isPinned'),
isLocked: mapValueOfType<bool>(json, r'isLocked'),
flagCount: mapValueOfType<double>(json, r'flagCount'),
displayLabel: mapValueOfType<String>(json, r'displayLabel'),
badges: CommentUserBadgeInfo.listFromJson(json[r'badges']),
verified: mapValueOfType<bool>(json, r'verified')!,
feedbackIds: json[r'feedbackIds'] is Iterable
? (json[r'feedbackIds'] as Iterable).cast<String>().toList(growable: false)
: const [],
isDeleted: mapValueOfType<bool>(json, r'isDeleted'),
);
}
return null;
}