IndexDatapoint.fromJson constructor

IndexDatapoint.fromJson(
  1. Object? j
)

Implementation

factory IndexDatapoint.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return IndexDatapoint(
    datapointId: switch (json['datapointId']) {
      null => '',
      Object $1 => decodeString($1),
    },
    featureVector: switch (json['featureVector']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) decodeDouble(i)],
      _ => throw const FormatException('"featureVector" is not a list'),
    },
    sparseEmbedding: switch (json['sparseEmbedding']) {
      null => null,
      Object $1 => IndexDatapoint_SparseEmbedding.fromJson($1),
    },
    restricts: switch (json['restricts']) {
      null => [],
      List<Object?> $1 => [
        for (final i in $1) IndexDatapoint_Restriction.fromJson(i),
      ],
      _ => throw const FormatException('"restricts" is not a list'),
    },
    numericRestricts: switch (json['numericRestricts']) {
      null => [],
      List<Object?> $1 => [
        for (final i in $1) IndexDatapoint_NumericRestriction.fromJson(i),
      ],
      _ => throw const FormatException('"numericRestricts" is not a list'),
    },
    crowdingTag: switch (json['crowdingTag']) {
      null => null,
      Object $1 => IndexDatapoint_CrowdingTag.fromJson($1),
    },
    embeddingMetadata: switch (json['embeddingMetadata']) {
      null => null,
      Object $1 => protobuf.Struct.fromJson($1),
    },
  );
}