///|
/// The format number of a file that Mission Control saves: a whole number of 1
/// or more. It is the only field that each format of a file has, so a reader
/// decodes it before the other fields.
///
/// The decoder accepts only a JSON number. A number above 2147483647 becomes
/// 2147483647, because such a format is newer and not damaged.
priv struct SavedFormat {
  format : Int32
}

///|
impl @json.FromJson for SavedFormat with fn from_json(json, path) {
  if json is Object(fields) &&
    fields.get("format") is Some(Number(number, ..)) &&
    number > project_largest_int.to_double() &&
    number == number.floor() {
    return { format: project_largest_int, }
  }
  let format : Int32 = project_file_field(json, path, "format")
  guard format >= 1 else {
    raise path.add_key("format").error("the format \{format} is less than 1")
  }
  { format, }
}