PredictRequest.fromJson constructor

PredictRequest.fromJson(
  1. Object? j
)

Implementation

factory PredictRequest.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return PredictRequest(
    endpoint: switch (json['endpoint']) {
      null => '',
      Object $1 => decodeString($1),
    },
    instances: switch (json['instances']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) protobuf.Value.fromJson(i)],
      _ => throw const FormatException('"instances" is not a list'),
    },
    parameters: switch (json['parameters']) {
      null => null,
      Object $1 => protobuf.Value.fromJson($1),
    },
    labels: switch (json['labels']) {
      null => {},
      Map<String, Object?> $1 => {
        for (final e in $1.entries)
          decodeString(e.key): decodeString(e.value),
      },
      _ => throw const FormatException('"labels" is not an object'),
    },
  );
}