Content.fromJson constructor

Content.fromJson(
  1. Object? j
)

Implementation

factory Content.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return Content(
    parts: switch (json['parts']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) Part.fromJson(i)],
      _ => throw const FormatException('"parts" is not a list'),
    },
    role: switch (json['role']) {
      null => '',
      Object $1 => decodeString($1),
    },
  );
}