fromJson static method

JournalStepError? fromJson(
  1. Object? raw
)

Tolerant decode: null for a missing or malformed object (a legacy journal never carries the field; a hand-edited one must not crash the reader).

Implementation

static JournalStepError? fromJson(Object? raw) {
  if (raw is! Map<String, dynamic>) return null;
  final behavior = raw['behavior'];
  final step = raw['step'];
  final outcome = raw['outcome'];
  final exitCode = raw['exit_code'];
  final command = raw['command'];
  final output = raw['output'];
  if (behavior is! String ||
      step is! String ||
      outcome is! String ||
      exitCode is! int ||
      command is! String ||
      output is! String) {
    return null;
  }
  return JournalStepError(
    behavior: behavior,
    step: step,
    outcome: outcome,
    exitCode: exitCode,
    command: command,
    output: output,
  );
}