asInt method

  1. @override
int asInt([
  1. int? defaultValue
])
override

The value as an int (Jackson 3): a finite number (truncated), a string of an integer ("42"), a boolean (1 / 0), 0 for null and a missing node. Anything else gives defaultValue, or throws a JsonNodeException without one; null and a missing node give defaultValue when there is one.

Implementation

@override
int asInt([int? defaultValue]) =>
    (_integer.hasMatch(value) ? int.tryParse(value) : null) ??
    super.asInt(defaultValue);