fromJson static method

ModerationAPIGetCommentIdsResponse? fromJson(
  1. dynamic value
)

Returns a new ModerationAPIGetCommentIdsResponse instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static ModerationAPIGetCommentIdsResponse? 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'ids'), 'Required key "ModerationAPIGetCommentIdsResponse[ids]" is missing from JSON.');
      assert(json[r'ids'] != null, 'Required key "ModerationAPIGetCommentIdsResponse[ids]" has a null value in JSON.');
      assert(json.containsKey(r'hasMore'), 'Required key "ModerationAPIGetCommentIdsResponse[hasMore]" is missing from JSON.');
      assert(json[r'hasMore'] != null, 'Required key "ModerationAPIGetCommentIdsResponse[hasMore]" has a null value in JSON.');
      assert(json.containsKey(r'status'), 'Required key "ModerationAPIGetCommentIdsResponse[status]" is missing from JSON.');
      assert(json[r'status'] != null, 'Required key "ModerationAPIGetCommentIdsResponse[status]" has a null value in JSON.');
      return true;
    }());

    return ModerationAPIGetCommentIdsResponse(
      ids: json[r'ids'] is Iterable
          ? (json[r'ids'] as Iterable).cast<String>().toList(growable: false)
          : const [],
      hasMore: mapValueOfType<bool>(json, r'hasMore')!,
      status: APIStatus.fromJson(json[r'status'])!,
    );
  }
  return null;
}