RealtimeTruncation.fromJson constructor

RealtimeTruncation.fromJson(
  1. Object json
)

Creates from JSON.

Accepts either the bare strings "auto"/"disabled" or an object with a type: "retention_ratio" discriminator. Any other shape returns an UnknownRealtimeTruncation preserving the raw payload.

Implementation

factory RealtimeTruncation.fromJson(Object json) {
  if (json == 'auto') return const TruncationAuto();
  if (json == 'disabled') return const TruncationDisabled();
  if (json is Map<String, dynamic>) {
    if (json['type'] == 'retention_ratio') {
      return TruncationRetentionRatio.fromJson(json);
    }
    return UnknownRealtimeTruncation(json);
  }
  return UnknownRealtimeTruncation({'value': json});
}