fromJson static method
Returns a new PubSubComment instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static PubSubComment? 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 "PubSubComment[_id]" is missing from JSON.');
assert(json[r'_id'] != null, 'Required key "PubSubComment[_id]" has a null value in JSON.');
assert(json.containsKey(r'tenantId'), 'Required key "PubSubComment[tenantId]" is missing from JSON.');
assert(json[r'tenantId'] != null, 'Required key "PubSubComment[tenantId]" has a null value in JSON.');
assert(json.containsKey(r'urlId'), 'Required key "PubSubComment[urlId]" is missing from JSON.');
assert(json[r'urlId'] != null, 'Required key "PubSubComment[urlId]" has a null value in JSON.');
assert(json.containsKey(r'commenterName'), 'Required key "PubSubComment[commenterName]" is missing from JSON.');
assert(json[r'commenterName'] != null, 'Required key "PubSubComment[commenterName]" has a null value in JSON.');
assert(json.containsKey(r'commentHTML'), 'Required key "PubSubComment[commentHTML]" is missing from JSON.');
assert(json[r'commentHTML'] != null, 'Required key "PubSubComment[commentHTML]" has a null value in JSON.');
assert(json.containsKey(r'comment'), 'Required key "PubSubComment[comment]" is missing from JSON.');
assert(json[r'comment'] != null, 'Required key "PubSubComment[comment]" has a null value in JSON.');
assert(json.containsKey(r'verified'), 'Required key "PubSubComment[verified]" is missing from JSON.');
assert(json[r'verified'] != null, 'Required key "PubSubComment[verified]" has a null value in JSON.');
assert(json.containsKey(r'url'), 'Required key "PubSubComment[url]" is missing from JSON.');
assert(json[r'url'] != null, 'Required key "PubSubComment[url]" has a null value in JSON.');
assert(json.containsKey(r'approved'), 'Required key "PubSubComment[approved]" is missing from JSON.');
assert(json[r'approved'] != null, 'Required key "PubSubComment[approved]" has a null value in JSON.');
assert(json.containsKey(r'locale'), 'Required key "PubSubComment[locale]" is missing from JSON.');
assert(json.containsKey(r'date'), 'Required key "PubSubComment[date]" is missing from JSON.');
assert(json[r'date'] != null, 'Required key "PubSubComment[date]" has a null value in JSON.');
return true;
}());
return PubSubComment(
id: mapValueOfType<String>(json, r'_id')!,
tenantId: mapValueOfType<String>(json, r'tenantId')!,
userId: mapValueOfType<String>(json, r'userId'),
urlId: mapValueOfType<String>(json, r'urlId')!,
commenterName: mapValueOfType<String>(json, r'commenterName')!,
commenterLink: mapValueOfType<String>(json, r'commenterLink'),
commentHTML: mapValueOfType<String>(json, r'commentHTML')!,
comment: mapValueOfType<String>(json, r'comment')!,
parentId: mapValueOfType<String>(json, r'parentId'),
votes: mapValueOfType<int>(json, r'votes'),
votesUp: mapValueOfType<int>(json, r'votesUp'),
votesDown: mapValueOfType<int>(json, r'votesDown'),
verified: mapValueOfType<bool>(json, r'verified')!,
avatarSrc: mapValueOfType<String>(json, r'avatarSrc'),
hasImages: mapValueOfType<bool>(json, r'hasImages'),
hasLinks: mapValueOfType<bool>(json, r'hasLinks'),
isByAdmin: mapValueOfType<bool>(json, r'isByAdmin'),
isByModerator: mapValueOfType<bool>(json, r'isByModerator'),
isPinned: mapValueOfType<bool>(json, r'isPinned'),
isLocked: mapValueOfType<bool>(json, r'isLocked'),
displayLabel: mapValueOfType<String>(json, r'displayLabel'),
rating: mapValueOfType<double>(json, r'rating'),
badges: CommentUserBadgeInfo.listFromJson(json[r'badges']),
viewCount: mapValueOfType<int>(json, r'viewCount'),
isDeleted: mapValueOfType<bool>(json, r'isDeleted'),
isDeletedUser: mapValueOfType<bool>(json, r'isDeletedUser'),
isSpam: mapValueOfType<bool>(json, r'isSpam'),
anonUserId: mapValueOfType<String>(json, r'anonUserId'),
feedbackIds: json[r'feedbackIds'] is Iterable
? (json[r'feedbackIds'] as Iterable).cast<String>().toList(growable: false)
: const [],
flagCount: mapValueOfType<int>(json, r'flagCount'),
domain: mapValueOfType<String>(json, r'domain'),
url: mapValueOfType<String>(json, r'url')!,
pageTitle: mapValueOfType<String>(json, r'pageTitle'),
expireAt: mapDateTime(json, r'expireAt', r''),
reviewed: mapValueOfType<bool>(json, r'reviewed'),
hasCode: mapValueOfType<bool>(json, r'hasCode'),
approved: mapValueOfType<bool>(json, r'approved')!,
locale: mapValueOfType<String>(json, r'locale'),
isBannedUser: mapValueOfType<bool>(json, r'isBannedUser'),
groupIds: json[r'groupIds'] is Iterable
? (json[r'groupIds'] as Iterable).cast<String>().toList(growable: false)
: const [],
isLive: mapValueOfType<bool>(json, r'isLive'),
hidden: mapValueOfType<bool>(json, r'hidden'),
date: mapValueOfType<String>(json, r'date')!,
);
}
return null;
}